#include <bits/stdc++.h>
using namespace std;
int d[500][500];
void f(int x, int y) {
  if (d[x][y] >= 4) {
    int k = d[x][y] / 4;
    d[x + 1][y] += k;
    d[x][y + 1] += k;
    d[x - 1][y] += k;
    d[x][y - 1] += k;
    d[x][y] -= k * 4;
    f(x + 1, y);
    f(x, y + 1);
    f(x - 1, y);
    f(x, y - 1);
  }
}
int main() {
  int n, t;
  cin >> n >> t;
  for (int i = 0; i < 500; i++)
    for (int j = 0; j < 500; j++) d[i][j] = 0;
  d[200][200] = n;
  f(200, 200);
  for (int i = 0; i < t; i++) {
    int x, y;
    cin >> x >> y;
    if (abs(x) > 200 || abs(y) > 200)
      cout << 0 << endl;
    else
      cout << d[x + 200][y + 200] << endl;
  }
}
