#include <bits/stdc++.h>
using namespace std;
int a[201][201] = {0};
int n, m;
int main(int argc, char *argv[]) {
  int x = 100;
  int y = 100;
  int ok = 0;
  cin >> n >> m;
  a[x][y] = n;
  do {
    ok = 0;
    int max = y;
    int min = x;
    for (int i = x; i <= y; i++)
      for (int j = x; j <= y; j++)
        if (a[i][j] >= 4) {
          ok = 1;
          int numofant = a[i][j];
          int mods = numofant % 4;
          int temp = (numofant - mods) / 4;
          a[i][j - 1] += temp;
          a[i][j + 1] += temp;
          a[i - 1][j] += temp;
          a[i + 1][j] += temp;
          a[i][j] = mods;
        }
    if (a[x - 1][100] >= 4) {
      x--;
      y++;
    }
  } while (ok == 1);
  long long u, v;
  int k[50005];
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    u += 100;
    v += 100;
    if (u > 200 || u < 0 || v > 200 || v < 0)
      k[i] = 0;
    else
      k[i] = a[u][v];
  }
  for (int i = 0; i < m; i++) cout << k[i] << endl;
  return EXIT_SUCCESS;
}
