#include <bits/stdc++.h>
using namespace std;
long n, calc, t, m, a, b;
long ar[2][160][160];
long liter;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> t;
  long shift = 70;
  ar[1][shift][shift] = n;
  liter = 1;
  long minn = shift;
  long maxx = shift;
  long miter = 0;
  long chan = 0;
  long nextt, cur;
  for (int iter = 1; iter <= 30000; iter++) {
    nextt = (iter & 1);
    nextt = 1 - nextt;
    cur = 1 - nextt;
    chan = 0;
    for (int i = minn; i <= maxx; i++)
      for (int j = minn; j <= maxx; j++) ar[nextt][i][j] = 0;
    for (int i = minn; i <= maxx; i++)
      for (int j = minn; j <= maxx; j++)
        if (ar[cur][i][j] >= 4) {
          chan = 1;
          ar[cur][i][j] -= 4;
          ar[nextt][i - 1][j]++;
          ar[nextt][i][j - 1]++;
          ar[nextt][i][j + 1]++;
          ar[nextt][i + 1][j]++;
          if (i == minn) --minn;
          if (i == maxx) ++maxx;
        }
    for (int i = minn; i <= maxx; i++)
      for (int j = minn; j <= maxx; j++) ar[nextt][i][j] += ar[cur][i][j];
    liter = iter + 1;
    if (chan == 0)
      break;
    else
      miter++;
  }
  for (int i = 1; i <= t; i++) {
    cin >> a >> b;
    a += shift;
    b += shift;
    if (a >= 1 && a <= 2 * shift && b >= 1 && b <= 2 * shift)
      cout << ar[liter & 1][a][b] << endl;
    else
      cout << 0 << endl;
  }
  cin.get();
  cin.get();
  return 0;
}
