#include <bits/stdc++.h>
using namespace std;
long long convertToNum(string s) {
  long long val = 0;
  for (int i = 0; i < (s.size()); i++) val = val * 10 + s[i] - '0';
  return val;
}
char bu[50];
string convertToString(int a) {
  sprintf(bu, "%d", a);
  return string(bu);
}
long long GCD(long long x, long long y) {
  if (!x) return y;
  if (!y) return x;
  if (x == y) return x;
  if (x < y)
    return GCD(x, y % x);
  else
    return GCD(x % y, y);
}
long long POW(long long x, long long y, long long Base) {
  if (!y) return 1;
  long long u = POW(x, y / 2, Base);
  u = (u * u) % Base;
  if (y % 2)
    return (u * x) % Base;
  else
    return u;
}
void extended_euclid(long long A, long long B, long long &x, long long &y) {
  if (A == 1 && B == 0) {
    x = 1;
    y = 0;
    return;
  }
  if (A < B)
    extended_euclid(B, A, y, x);
  else {
    long long xx, yy;
    extended_euclid(A % B, B, xx, yy);
    x = xx;
    y = yy - (A / B) * xx;
  }
}
set<pair<int, pair<int, int> > > se;
map<pair<int, int>, int> Map;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
int n, q;
int res[1000][1000];
int TEST;
int maxC = 100;
int dd[1000][1000];
vector<pair<int, int> > ls[2];
int main() {
  cin >> n >> q;
  res[0 + maxC][0 + maxC] = n;
  ls[0].push_back(make_pair(0, 0));
  int flag = 0;
  for (int iter = 0; iter < (30000); iter++) {
    TEST++;
    ls[1 - flag].clear();
    if (!ls[flag].size()) {
      break;
    }
    for (int i = 0; i < (ls[flag].size()); i++) {
      int u = ls[flag][i].first, v = ls[flag][i].second;
      int delta = res[u + maxC][v + maxC];
      if (delta >= 4) {
        for (int k = 0; k < (4); k++) {
          res[u + dx[k] + maxC][v + dy[k] + maxC] += delta / 4;
          if (res[u + dx[k] + maxC][v + dy[k] + maxC] >= 4 &&
              dd[u + dx[k] + maxC][v + dy[k] + maxC] != TEST) {
            dd[u + dx[k] + maxC][v + dy[k] + maxC] = TEST;
            ls[1 - flag].push_back(make_pair(u + dx[k], v + dy[k]));
          }
        }
        res[u + maxC][v + maxC] -= (delta / 4) * 4;
      }
    }
    flag = !flag;
  }
  int u, v;
  for (int i = (1); i <= (q); i++) {
    scanf("%d%d", &u, &v);
    if (abs(u) > 90 || abs(v) > 90)
      printf("0\n");
    else
      printf("%d\n", res[u + maxC][v + maxC]);
  }
  return 0;
}
