#include <bits/stdc++.h>
long f[4005][4005];
void dfs(long x, long y) {
  while (f[x][y] >= 4) {
    f[x][y] -= 4;
    f[x][y + 1] += 1;
    dfs(x, y + 1);
    f[x][y - 1] += 1;
    dfs(x, y - 1);
    f[x + 1][y] += 1;
    dfs(x + 1, y);
    f[x - 1][y] += 1;
    dfs(x - 1, y);
  }
  return;
}
int main() {
  long n, m, i, x, y;
  scanf("%ld%ld", &n, &m);
  f[2000][2000] = n;
  dfs(2000, 2000);
  for (i = 1; i <= m; i++) {
    scanf("%ld%ld", &x, &y);
    if (x > 2000 || y > 2000 || x < -2000 || y < -2000)
      printf("0\n");
    else
      printf("%ld\n", f[x + 2000][y + 2000]);
  }
}
