#include <bits/stdc++.h>
using namespace std;
int neigh[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
int a[200][200];
int main() {
  int i, j, k, m, n, tmp, x, y;
  memset(a, 0, sizeof(a));
  vector<pair<int, int> > q;
  scanf("%d%d", &n, &m);
  q.clear();
  q.push_back(make_pair(100, 100));
  a[100][100] = n;
  for (i = 0; i < q.size(); i++) {
    tmp = a[q[i].first][q[i].second] / 4;
    a[q[i].first][q[i].second] %= 4;
    for (j = 0; j < 4; j++) {
      x = q[i].first + neigh[j][0];
      y = q[i].second + neigh[j][1];
      a[x][y] += tmp;
      if ((a[x][y] - tmp < 4) && (a[x][y] >= 4)) q.push_back(make_pair(x, y));
    }
  }
  for (i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    if ((abs(x) >= 100) || (abs(y) >= 100))
      printf("0\n");
    else
      printf("%d\n", a[x + 100][y + 100]);
  }
}
