#include <bits/stdc++.h>
using namespace std;
int graph[3000][3000];
void solve(int x, int y) {
  if (graph[x][y] < 4) {
    return;
  }
  int t = graph[x][y] / 4;
  graph[x][y] = graph[x][y] % 4;
  graph[x - 1][y] += t;
  graph[x][y - 1] += t;
  graph[x + 1][y] += t;
  graph[x][y + 1] += t;
  solve(x - 1, y);
  solve(x, y - 1);
  solve(x + 1, y);
  solve(x, y + 1);
}
int main() {
  int n, t, x, y;
  cin >> n >> t;
  graph[1500][1500] = n;
  solve(1500, 1500);
  while (t--) {
    cin >> x >> y;
    x = x + 1500;
    y = y + 1500;
    if (x < 0 || x >= 3000 || y < 0 || y >= 3000) {
      cout << 0 << endl;
    } else {
      cout << graph[x][y] << endl;
    }
  }
}
