#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007, dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
const double eps = 1e-8;
void read(int &k) {
  k = 0;
  char x = getchar();
  while (x < '0' || x > '9') x = getchar();
  while (x >= '0' && x <= '9') {
    k = k * 10 - 48 + x;
    x = getchar();
  }
}
int N, q, a[210][210], b[210][210], x, y;
int main() {
  scanf("%d%d", &N, &q);
  a[70][70] = N;
  int dead = 1;
  while (dead) {
    dead = 0;
    memset(b, 0, sizeof b);
    for (int i = 1; i < 140; i++)
      for (int j = 1; j < 140; j++)
        if (a[i][j] >= 4) {
          for (int dir = 0; dir < 4; dir++)
            b[i + dx[dir]][j + dy[dir]] += a[i][j] / 4;
          a[i][j] %= 4;
          dead = 1;
        }
    for (int i = 1; i < 140; i++)
      for (int j = 1; j < 140; j++) b[i][j] += a[i][j];
    memcpy(a, b, sizeof a);
  }
  for (; q--;) {
    scanf("%d%d", &x, &y);
    if (70 + x > 0 && 70 + x < 140 && 70 + y > 0 && 70 + y < 140)
      printf("%d\n", a[70 + x][70 + y]);
    else
      printf("%d\n", 0);
  }
  return 0;
}
