#include <bits/stdc++.h>
using namespace std;
int a[610][610], i, j, n, q, x, y;
void dfs(int x, int y) {
  if (a[x][y] >= 4) {
    int d = a[x][y] / 4;
    a[x - 1][y] += d;
    a[x + 1][y] += d;
    a[x][y - 1] += d;
    a[x][y + 1] += d;
    a[x][y] -= 4 * d;
    dfs(x - 1, y);
    dfs(x + 1, y);
    dfs(x, y - 1);
    dfs(x, y + 1);
  }
}
int main() {
  scanf("%d%d", &n, &q);
  a[300][300] = n;
  dfs(300, 300);
  for (i = 1; i <= q; ++i) {
    scanf("%d%d", &x, &y);
    if (abs(x) + abs(y) <= 300)
      printf("%d\n", a[300 + x][300 + y]);
    else
      printf("0\n");
  }
}
