#include <bits/stdc++.h>
using namespace std;
int g_array[140][140] = {0};
int g_center = 70;
int main(int argc, const char* argv[]) {
  std::ios_base::sync_with_stdio(0);
  int n = 0;
  int t = 0;
  cin >> n >> t;
  g_array[g_center][g_center] = n;
  int minc = g_center - 1;
  int maxc = g_center + 1;
  while (true) {
    bool end = true;
    for (int x = minc; x < maxc; ++x) {
      for (int y = minc; y < maxc; ++y) {
        int current = g_array[x][y];
        if (current < 4) continue;
        end = false;
        int mod = current % 4;
        int quarter = (current - mod) / 4;
        g_array[x + 1][y] += quarter;
        g_array[x - 1][y] += quarter;
        g_array[x][y + 1] += quarter;
        g_array[x][y - 1] += quarter;
        g_array[x][y] = mod;
      }
    }
    if (minc > 1) {
      --minc;
    }
    if (maxc < 140) {
      ++maxc;
    }
    if (end) {
      break;
    }
  }
  std::stringstream outStream;
  for (int i = 0; i < t; ++i) {
    int64_t a = 0;
    int64_t b = 0;
    cin >> a >> b;
    if (abs(a) + g_center >= 140 || abs(b) + g_center >= 140) {
      outStream << 0 << endl;
      continue;
    }
    outStream << g_array[a + g_center][b + g_center] << endl;
  }
  cout << outStream.str();
  return 0;
}
