#include <bits/stdc++.h>
int arr[400][400];
void f(int x, int y) {
  if (arr[x][y] < 4) return;
  arr[x][y + 1] += arr[x][y] / 4;
  arr[x][y - 1] += arr[x][y] / 4;
  arr[x + 1][y] += arr[x][y] / 4;
  arr[x - 1][y] += arr[x][y] / 4;
  arr[x][y] %= 4;
  f(x, y + 1);
  f(x, y - 1);
  f(x + 1, y);
  f(x - 1, y);
}
int main() {
  int n, t, i;
  scanf("%d %d", &n, &t);
  arr[200][200] = n;
  f(200, 200);
  for (i = 0; i < t; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    if (x + 200 > 400 || y + 200 > 400 || x + 200 < 0 || y + 200 < 0)
      printf("0\n");
    else
      printf("%d\n", arr[x + 200][y + 200]);
  }
  return 0;
}
