#include <bits/stdc++.h>
using namespace std;
int a, b, x, y;
int v[1005][1005];
void tp(int m, int n, int k) {
  v[m][n] += k;
  if (v[m][n] < 4) return;
  v[m][n] -= 4;
  tp(m, n, 0);
  tp(m + 1, n, 1);
  tp(m - 1, n, 1);
  tp(m, n + 1, 1);
  tp(m, n - 1, 1);
  return;
}
int main() {
  scanf("%d %d", &a, &b);
  tp(500, 500, a);
  for (int i = 0; i < b; i++) {
    scanf("%d %d", &x, &y);
    if (x > 500 || y > 500 || x < -500 || y < -500) {
      printf("0\n");
      continue;
    }
    printf("%d\n", v[x + 500][y + 500]);
  }
}
