#include <bits/stdc++.h>
using namespace std;
void stop() {
  printf("press any key to continue...\n");
  while (getchar() != '\n') {
  }
}
const int LEN = 131;
int ants[2][LEN][LEN];
void print(int t) {
  for (int y = 0; y < LEN; y++) {
    for (int x = 0; x < LEN; x++) {
      if (ants[t][y][x] == 0) {
        cout << ' ';
      } else {
        printf("%d", ants[t][y][x]);
      }
    }
    cout << endl;
  }
}
int main() {
  istream& in = cin;
  int n, t;
  in >> n >> t;
  memset(ants, 0, sizeof(ants));
  ants[0][LEN / 2][LEN / 2] = n;
  int d = 1;
  int s = 0;
  while (true) {
    bool update = false;
    memset(ants[d], 0, sizeof(ants[d]));
    for (int y = 0; y < LEN; y++) {
      for (int x = 0; x < LEN; x++) {
        if (ants[s][y][x] >= 4) {
          if (y == 0) {
            cout << endl;
          }
          update = true;
          int add = ants[s][y][x] / 4;
          int rem = ants[s][y][x] % 4;
          ants[d][y][x + 1] += add;
          ants[d][y][x - 1] += add;
          ants[d][y + 1][x] += add;
          ants[d][y - 1][x] += add;
          ants[d][y][x] += rem;
        } else {
          ants[d][y][x] += ants[s][y][x];
        }
      }
    }
    if (!update) break;
    swap(s, d);
  }
  int MAX_ABS = LEN / 2;
  for (int i = 0; i < t; i++) {
    int x, y;
    in >> x >> y;
    if (abs(x) > MAX_ABS || abs(y) > MAX_ABS) {
      printf("%d\n", 0);
    } else {
      x += LEN / 2;
      y += LEN / 2;
      printf("%d\n", ants[s][y][x]);
    }
  }
}
