#include <bits/stdc++.h>
using namespace std;
int n, t;
int ans[2 * 1000][2 * 1000];
int directs[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {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 + directs[i][0];
    int y2 = y + directs[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 temp1, temp2;
    scanf("%d %d", &temp1, &temp2);
    temp1 += 1000;
    temp2 += 1000;
    if (temp1 < 0 || temp1 >= 2 * 1000 || temp2 < 0 || temp2 >= 2 * 1000)
      printf("0\n");
    else
      printf("%d\n", ans[temp1][temp2]);
  }
  return 0;
}
