#include <bits/stdc++.h>
using namespace std;
const int MAX = 100;
const int pivot = 200;
int n, q;
int x, y;
int lat[400][400];
int main() {
  scanf("%d %d", &n, &q);
  lat[pivot][pivot] = n;
  while (true) {
    bool change = false;
    for (int i = pivot - MAX; i <= pivot + MAX; i++)
      for (int j = pivot - MAX; j <= pivot + MAX; j++)
        if (lat[i][j] >= 4) {
          change = true;
          int go = lat[i][j] / 4;
          lat[i][j] %= 4;
          lat[i + 1][j] += go;
          lat[i - 1][j] += go;
          lat[i][j + 1] += go;
          lat[i][j - 1] += go;
        }
    if (!change) break;
  }
  for (int i = 1; i <= q; i++) {
    scanf("%d %d", &x, &y);
    if (abs(x) > MAX || abs(y) > MAX) {
      printf("0\n");
    } else {
      printf("%d\n", lat[pivot + y][pivot + x]);
    }
  }
  return 0;
}
