#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, arr[200][200] = {0}, u, v;
  bool done = false;
  cin >> n >> q;
  arr[99][99] = n;
  while (!done) {
    done = true;
    for (int x = 0; x < 200; ++x) {
      for (int y = 0; y < 200; ++y) {
        if (arr[x][y] >= 4) {
          done = false;
          if (x + 1 < 200) arr[x + 1][y] += arr[x][y] / 4;
          if (x - 1 >= 0) arr[x - 1][y] += arr[x][y] / 4;
          if (y + 1 < 200) arr[x][y + 1] += arr[x][y] / 4;
          if (y - 1 >= 0) arr[x][y - 1] += arr[x][y] / 4;
          arr[x][y] %= 4;
        }
      }
    }
  }
  while (q--) {
    cin >> u >> v;
    if (u + 99 >= 200 || u + 99 < 0 || v + 99 >= 200 || v + 99 < 0)
      cout << 0 << endl;
    else
      cout << arr[u + 99][v + 99] << endl;
  }
  return 0;
}
