#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = ((ans % m) * (a % m)) % m;
    b /= 2;
    a = ((a % m) * (a % m)) % m;
  }
  return ans % m;
}
int dr[] = {-1, 1, 0, 0};
int dc[] = {0, 0, 1, -1};
int m[3000][3000];
void process(int n) {
  queue<pair<int, int> > q;
  q.push(make_pair(1500, 1500));
  m[1500][1500] = n;
  while (!q.empty()) {
    int x = q.front().first;
    int y = q.front().second;
    int cnt = m[x][y];
    if (cnt < 4) {
      m[x][y] = cnt;
      q.pop();
      continue;
    } else {
      m[x][y] = cnt % 4;
      q.pop();
      for (int i = 0; i < 4; i++) {
        q.push(make_pair(x + dr[i], y + dc[i]));
        m[x + dr[i]][y + dc[i]] += cnt / 4;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, t;
  cin >> n >> t;
  process(n);
  int a, b;
  for (int i = 0; i < t; i++) {
    cin >> a >> b;
    if (a + 1500 >= 3000 || b + 1500 >= 3000 || a + 1500 < 0 || b + 1500 < 0) {
      cout << "0"
           << "\n";
    } else {
      cout << m[a + 1500][b + 1500] << "\n";
    }
  }
}
