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