#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int ace[120][120], now[120][120];
void fun(int n) {
  ace[0][0] = n;
  int i, j, k;
  int my = 1, x, y;
  ;
  while (my) {
    my = 0;
    for (int i = 0; i <= 100; i++) {
      for (int j = 0; j <= 100; j++) {
        now[i][j] = ace[i][j];
      }
    }
    for (i = 0; i <= 100; i++) {
      for (int j = 0; j <= 100; j++) {
        if (now[i][j] >= 4) {
          for (int k = 0; k < 4; k++) {
            x = dx[k] + i;
            y = dy[k] + j;
            if (x < 0 or y < 0) continue;
            ace[x][y]++;
            if (x == 0 && i != x) ace[x][y]++;
            if (y == 0 && j != y) ace[x][y]++;
          }
          ace[i][j] -= 4;
          my = 1;
        }
      }
    }
    for (int i = 0; i <= 100; i++) {
      for (int j = 0; j <= 100; j++) {
        now[i][j] = ace[i][j];
      }
    }
  }
}
int main() {
  int i, j, k, l, m, n, t;
  scanf("%d%d", &n, &t);
  fun(n);
  while (t--) {
    scanf("%d%d", &i, &j);
    i = abs(i);
    j = abs(j);
    if (i > 100 || j > 100)
      printf("0\n");
    else
      printf("%d\n", ace[i][j]);
  }
}
