#include <bits/stdc++.h>
using namespace std;
const int SZ = 100;
int cnt[2 * SZ + 1][2 * SZ + 1];
int used[2 * SZ + 1][2 * SZ + 1];
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
const int MX = 11111;
int Px[MX], Py[MX], s = 0, e = 0;
void push(int first, int second) {
  Px[e] = first;
  Py[e++] = second;
  if (e >= MX) e -= MX;
}
void pop() {
  s++;
  if (s >= MX) s -= MX;
}
int main() {
  int n, t;
  scanf("%d%d", &n, &t);
  cnt[0 + SZ][0 + SZ] = n;
  push(0, 0);
  while (s != e) {
    int tx = Px[s], ty = Py[s];
    pop();
    if (cnt[tx + SZ][ty + SZ] >= 4) {
      for (int k = (0); k <= ((4) - 1); k++) {
        int was = cnt[tx + dx[k] + SZ][ty + dy[k] + SZ];
        cnt[tx + dx[k] + SZ][ty + dy[k] + SZ] += cnt[tx + SZ][ty + SZ] / 4;
        if (was < 4 && cnt[tx + dx[k] + SZ][ty + dy[k] + SZ] >= 4) {
          push(tx + dx[k], ty + dy[k]);
        }
      }
      cnt[tx + SZ][ty + SZ] %= 4;
    }
  }
  for (int i = (0); i <= ((t)-1); i++) {
    int first, second;
    scanf("%d%d", &first, &second);
    if (abs(first) >= 80 || abs(second) >= 80)
      printf("0\n");
    else
      printf("%d\n", cnt[first + SZ][second + SZ]);
  }
  return 0;
}
