#include <bits/stdc++.h>
using namespace std;
queue<pair<int, int> > q;
int ht[205][205], tmp[205][205];
map<pair<int, int>, int>::iterator its;
int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int n, t;
  cin >> n >> t;
  ht[100][100] = n;
  while (1) {
    bool check = 0;
    for (int i = 0; i <= 200; i++) {
      for (int j = 0; j <= 200; j++) {
        if (ht[i][j] < 4) continue;
        check = 1;
        for (int k = 0; k < 4; k++)
          tmp[i + dir[k][0]][j + dir[k][1]] += ht[i][j] / 4;
        ht[i][j] %= 4;
      }
    }
    if (!check) break;
    for (int i = 0; i <= 200; i++) {
      for (int j = 0; j <= 200; j++) {
        ht[i][j] += tmp[i][j];
        tmp[i][j] = 0;
      }
    }
  }
  while (t--) {
    int uy, ux;
    cin >> uy >> ux;
    uy += 100, ux += 100;
    if (uy < 0 || uy > 200 || ux < 0 || ux > 200)
      printf("0\n");
    else
      printf("%d\n", ht[uy][ux]);
  }
}
