#include <bits/stdc++.h>
using namespace std;
int n, t;
int ans[2 * 1000][2 * 1000];
int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
void dfs(int x, int y) {
  if (ans[x][y] < 4) return;
  int t = ans[x][y] / 4;
  ans[x][y] %= 4;
  for (int i = 0; i < 4; i++) {
    int x2 = x + dir[i][0];
    int y2 = y + dir[i][1];
    ans[x2][y2] += t;
    dfs(x2, y2);
  }
}
int main() {
  scanf("%d%d", &n, &t);
  ans[1000][1000] = n;
  dfs(1000, 1000);
  for (int i = 0; i < t; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x += 1000;
    y += 1000;
    if (x < 0 || x >= 2 * 1000 || y < 0 || y >= 2 * 1000)
      printf("0\n");
    else
      printf("%d\n", ans[x][y]);
  }
  return 0;
}
