#include <bits/stdc++.h>
using namespace std;
int cnt[300][300], vst[300][300], flag, q[1000000];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
  int N, z, T, qb, qf, x, y, i, xx, yy;
  while (scanf("%d%d", &N, &T) == 2) {
    memset(cnt, 0, sizeof(cnt));
    cnt[150][150] = N;
    qb = qf = 0;
    if (N >= 4) {
      q[qb++] = 150;
      q[qb++] = 150;
    }
    flag++;
    while (qf != qb) {
      x = q[qf++];
      if (qf == 1000000) qf = 0;
      y = q[qf++];
      if (qf == 1000000) qf = 0;
      vst[x][y] = 0;
      cnt[x][y] -= 4;
      for (i = 0; i < 4; i++) {
        xx = x + dx[i];
        yy = y + dy[i];
        cnt[xx][yy]++;
        if (cnt[xx][yy] >= 4) {
          if (vst[xx][yy] != flag) {
            vst[xx][yy] = flag;
            q[qb++] = xx;
            if (qb == 1000000) qb = 0;
            q[qb++] = yy;
            if (qb == 1000000) qb = 0;
          }
        }
      }
      if (cnt[x][y] >= 4) {
        vst[x][y] = flag;
        q[qb++] = x;
        if (qb == 1000000) qb = 0;
        q[qb++] = y;
        if (qb == 1000000) qb = 0;
      }
    }
    for (; T--;) {
      scanf("%d%d", &x, &y);
      if ((x + 150 < 0 || x + 150 >= 300 || y + 150 < 0 || y + 150 >= 300))
        puts("0");
      else
        printf("%d\n", cnt[x + 150][y + 150]);
    }
  }
  return 0;
}
