#include <bits/stdc++.h>
using namespace std;
struct point {
  int x;
  int y;
};
bool operator<(const point &a, const point &b) { return (a.x < b.x); }
int compare(const void *a, const void *b) { return (*(int *)a - *(int *)b); }
int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }
int a[200][200];
int main() {
  int n, t, i, j, x, y;
  cin >> n >> t;
  a[100][100] = n;
  while (1) {
    int flag = 0;
    for (i = 0; i < 200; i++)
      for (j = 0; j < 200; j++)
        if (a[i][j] >= 4) {
          if (i > 0) a[i - 1][j] += (a[i][j] / 4);
          if (i < 199) a[i + 1][j] += (a[i][j] / 4);
          if (j > 0) a[i][j - 1] += (a[i][j] / 4);
          if (j < 199) a[i][j + 1] += (a[i][j] / 4);
          flag = 1;
          a[i][j] %= 4;
        }
    if (!flag) break;
  }
  for (i = 0; i < t; i++) {
    cin >> x >> y;
    if (x < 100 && x >= -100 && y < 100 && y >= -100)
      cout << a[x + 100][y + 100] << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}
