#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > a[2];
int n, t;
int add = 100;
int minx = add, maxx = add;
int main() {
  a[0].resize(210);
  a[1].resize(210);
  for (int i = 0; i < 210; i++) a[0][i].resize(210), a[1][i].resize(210);
  cin >> n >> t;
  a[1][add][add] = n;
  while (1 == 1) {
    bool fl = 0;
    a[0].swap(a[1]);
    for (int i = minx; i <= maxx; i++)
      for (int j = minx; j <= maxx; j++) a[1][i][j] = a[0][i][j];
    for (int i = minx; i <= maxx; i++)
      for (int j = minx; j <= maxx; j++) {
        if (a[0][i][j] >= 4) {
          fl = 1;
          minx = min(minx, i - 1);
          minx = min(minx, j - 1);
          maxx = max(maxx, i + 1);
          maxx = max(maxx, j + 1);
          a[1][i + 1][j] += a[1][i][j] / 4;
          a[1][i - 1][j] += a[1][i][j] / 4;
          a[1][i][j - 1] += a[1][i][j] / 4;
          a[1][i][j + 1] += a[1][i][j] / 4;
          a[1][i][j] %= 4;
        }
      }
    if (fl == 0) break;
  }
  for (int i = 0; i < t; i++) {
    int xx, yy;
    scanf("%d%d", &xx, &yy);
    xx += add;
    yy += add;
    if (min(xx, yy) < minx || max(xx, yy) > maxx)
      printf("%d\n", 0);
    else
      printf("%d\n", a[1][xx][yy]);
  }
  return 0;
}
