#include <bits/stdc++.h>
using namespace std;
int constructAntGrid(int curx, int cury, int m[1000][1000]) {
  if (m[curx][cury] < 4) {
    return 0;
  }
  m[curx][cury + 1] += m[curx][cury] / 4;
  m[curx + 1][cury] += m[curx][cury] / 4;
  m[curx][cury - 1] += m[curx][cury] / 4;
  m[curx - 1][cury] += m[curx][cury] / 4;
  m[curx][cury] %= 4;
  constructAntGrid(curx + 1, cury, m);
  constructAntGrid(curx, cury + 1, m);
  constructAntGrid(curx - 1, cury, m);
  constructAntGrid(curx, cury - 1, m);
  return 0;
}
int main(int argc, char *argv[]) {
  int n_ants, n_queries;
  cin >> n_ants >> n_queries;
  int m[1000][1000];
  m[500][500] = n_ants;
  constructAntGrid(500, 500, m);
  for (int i = 0; i < n_queries; i++) {
    long long int x, y;
    cin >> x >> y;
    if (500 + x >= 1000 || 500 + y >= 1000 || 500 + y < 0 || 500 + x < 0)
      cout << 0 << endl;
    else
      cout << m[500 + x][500 + y] << endl;
  }
}
