#include <bits/stdc++.h>
int dh[4] = {-1, 0, 1, 0}, dw[4] = {0, 1, 0, -1};
int cnt[2 * 70][2 * 70];
void doit(int a, int b) {
  int i, j, k, c = cnt[a][b] / 4;
  for (k = 0; k < 4; k++) {
    i = a + dh[k];
    j = b + dw[k];
    cnt[i][j] += c;
  }
  cnt[a][b] -= 4 * c;
}
int main() {
  int i, j, n, t, a, b;
  bool bf = 1;
  scanf("%d%d", &n, &t);
  cnt[70][70] = n;
  while (bf) {
    bf = 0;
    for (i = 1; i < 2 * 70; i++)
      for (j = 1; j < 2 * 70; j++)
        if (cnt[i][j] >= 4) {
          doit(i, j);
          bf = 1;
        }
  }
  while (t--) {
    scanf("%d%d", &a, &b);
    if (a + 70 < 1 || a + 70 >= 2 * 70 || b + 70 < 1 || b + 70 >= 2 * 70)
      puts("0");
    else
      printf("%d\n", cnt[a + 70][b + 70]);
  }
}
