#include <bits/stdc++.h>
int main() {
  static int kk[200 + 1 + 200][200 + 1 + 200];
  int n, t, x, y, k, updated;
  scanf("%d%d", &n, &t);
  kk[200][200] = n;
  while (1) {
    updated = 0;
    for (x = 1; x < 200 + 200; x++)
      for (y = 1; y < 200 + 200; y++)
        if (kk[x][y] >= 4) {
          k = kk[x][y] / 4;
          kk[x][y] %= 4;
          kk[x - 1][y] += k;
          kk[x + 1][y] += k;
          kk[x][y - 1] += k;
          kk[x][y + 1] += k;
          updated = 1;
        }
    if (!updated) break;
  }
  while (t--) {
    scanf("%d%d", &x, &y);
    printf("%d\n", x < -200 || x > 200 || y < -200 || y > 200
                       ? 0
                       : kk[200 + x][200 + y]);
  }
  return 0;
}
