#include <bits/stdc++.h>
using namespace std;
int v[202][202];
struct node2 {
  map<int, int> q;
};
int path[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
int mm;
void solve(int n) {
  memset(v, 0, sizeof(v));
  v[100][100] = n;
  int i, j;
  while (1) {
    int f = 0;
    for (i = 0; i < 200; i++) {
      for (j = 0; j < 200; j++) {
        if (v[i][j] >= 4) {
          for (int k = 0; k < 4; k++) {
            int x = i + path[k][0];
            int y = j + path[k][1];
            v[x][y] += v[i][j] / 4;
          }
          f = 1;
          v[i][j] %= 4;
        }
      }
    }
    if (f == 0) break;
  }
}
int main() {
  int n, t;
  while (scanf("%d%d", &n, &t) != EOF) {
    solve(n);
    while (t--) {
      int x, y;
      scanf("%d%d", &x, &y);
      x += 100;
      y += 100;
      if (x >= 0 && x < 200 && y >= 0 && y < 200)
        printf("%d\n", v[x][y]);
      else
        printf("%d\n", 0);
    }
  }
  return 0;
}
