#include <bits/stdc++.h>
using namespace std;
int M[132][132][2];
int f(int x) { return x + 132 / 2; }
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
bool in(int x, int y) { return abs(x) < 132 / 2 && abs(y) < 132 / 2; }
int main() {
  memset(M, 0, sizeof M);
  int n, t, a = 0, est = 0, x, y;
  scanf("%d%d", &n, &t);
  M[f(0)][f(0)][0] = n;
  bool ok = 1;
  while (ok) {
    ok = 0;
    for (int i = -a; i <= a; i++)
      for (int j = -a; j <= a; j++) {
        if (M[f(i)][f(j)][est] > 3) {
          ok = 1;
          for (int k = 0; k < 4; k++)
            M[f(i + dx[k])][f(j + dy[k])][!est] += M[f(i)][f(j)][est] / 4;
          M[f(i)][f(j)][!est] = M[f(i)][f(j)][est] % 4;
          M[f(i)][f(j)][est] = 0;
        } else {
          M[f(i)][f(j)][!est] += M[f(i)][f(j)][est];
          M[f(i)][f(j)][est] = 0;
        }
      }
    if (M[f(a + 1)][f(0)][!est] != 0) a++;
    est = !est;
  }
  while (t--) {
    scanf("%d%d", &x, &y);
    if (in(x, y))
      printf("%d\n", M[f(x)][f(y)][est]);
    else
      puts("0");
  }
}
