#include <bits/stdc++.h>
using namespace std;
int arr[2][200][200];
stack<int> s1, s2;
int computeIterative(void) {
  int pre = 0;
  int now = 1;
  while (true) {
    bool changed = false;
    for (int i = 0; i < 200; i++) {
      for (int j = 0; j < 200; j++) {
        arr[now][i][j] += arr[pre][i][j];
        if (arr[pre][i][j] >= 4) {
          changed = true;
          int inc = arr[pre][i][j] / 4;
          int dec = 4 * inc;
          arr[now][i][j] -= dec;
          arr[now][i + 1][j] += inc;
          arr[now][i - 1][j] += inc;
          arr[now][i][j + 1] += inc;
          arr[now][i][j - 1] += inc;
        }
      }
    }
    if (!changed) return now;
    memset(arr[pre], 0, sizeof(arr[pre]));
    pre = 1 - pre;
    now = 1 - now;
  }
}
int main() {
  int n, t;
  scanf("%d %d", &n, &t);
  memset(arr, 0, sizeof(arr));
  arr[0][100][100] = n;
  int ver = computeIterative();
  for (int i = 0; i < t; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    if (x >= 100 || x < -100 || y >= 100 || y < -100)
      printf("0\n");
    else {
      printf("%d\n", arr[ver][x + 100][y + 100]);
    }
  }
  return 0;
}
