#include <bits/stdc++.h>
using namespace std;
int main() {
  const int N = 64;
  int a[2 * N + 1][2 * N + 1] = {{0}};
  int n, t;
  scanf("%d %d", &n, &t);
  a[N][N] = n;
  bool finished = false;
  while (!finished) {
    bool all_under = true;
    for (int i = 0; i < 2 * N + 1 && all_under; i++) {
      for (int j = 0; j < 2 * N + 1; j++) {
        if (a[i][j] >= 4) {
          all_under = false;
          break;
        }
      }
    }
    if (all_under) {
      finished = true;
      break;
    }
    int b[2 * N + 1][2 * N + 1] = {{0}};
    for (int i = 0; i < 2 * N + 1; i++) {
      for (int j = 0; j < 2 * N + 1; j++) {
        int temp = a[i][j] / 4;
        if (a[i][j] >= 4) {
          b[i - 1][j] += temp;
          b[i + 1][j] += temp;
          b[i][j - 1] += temp;
          b[i][j + 1] += temp;
          a[i][j] -= 4 * temp;
        }
      }
    }
    for (int i = 0; i < 2 * N + 1; i++) {
      for (int j = 0; j < 2 * N + 1; j++) {
        a[i][j] += b[i][j];
      }
    }
  }
  int x, y;
  while (t--) {
    scanf("%d %d", &x, &y);
    if (x < -N || x > N || y < -N || y > N) {
      printf("0\n");
    } else {
      printf("%d\n", a[x + N][y + N]);
    }
  }
  return 0;
}
