#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)((1e5) + 10);
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int max(int a, int b) {
  if (a > b)
    return a;
  else
    return b;
}
int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
bool isPrime(int N) {
  for (int i = 2; i * i <= N; ++i) {
    if (N % i == 0) return false;
  }
  return true;
}
int cbrt(int x) {
  int lo = 1, hi = min(2000000ll, x);
  while (hi - lo > 1) {
    int mid = (lo + hi) / 2;
    if (mid * mid * mid < x) {
      lo = mid;
    } else
      hi = mid;
  }
  if (hi * hi * hi <= x)
    return hi;
  else
    return lo;
}
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int nax = (int)(100000 + 10);
vector<string> v;
vector<int> vec[27], adj[200005];
stack<int> st;
string ss;
int a, b, c, d, n, m, k = 0, f = 0, ans1 = 0, ans = 0, h = 0, t, res = 0,
                      cost = 0;
int dist[2][200502], arr[9000], has[90000], pre[9000];
int ab[505][505], vis[505][505];
struct cell {
  int x, y;
  cell() {}
  cell(int x, int y) : x(x), y(y) {}
};
void bfs(int x1, int x2) {
  queue<cell> que;
  cell t;
  que.push(cell(x1, x2));
  vis[x1][x2] = 1;
  while (!que.empty()) {
    t = que.front();
    que.pop();
    int c = ab[t.x][t.y] / 4;
    vis[t.x][t.y] = 0;
    ab[t.x][t.y] = ab[t.x][t.y] % 4;
    for (int i = 0; i < 4; i++) {
      int x = t.x + dx[i];
      int y = t.y + dy[i];
      ab[x][y] += c;
      if (ab[x][y] >= 4 && !vis[x][y]) {
        que.push(cell(x, y));
        vis[x][y] = 1;
      }
    }
  }
}
int main() {
  cin >> n >> t;
  ab[250][250] = n;
  if (n >= 4) {
    bfs(250, 250);
  }
  while (t--) {
    cin >> a >> b;
    if (abs(a) > 250 || abs(b) > 250) {
      cout << '0' << "\n";
    } else {
      cout << ab[a + 250][b + 250] << "\n";
    }
  }
  return 0;
}
