#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int INF = 2e9;
const int MOD = 1e9 + 7;
int dp[202][202], N = 0, T = 0;
int main() {
  scanf("%i%i", &N, &T);
  dp[100][100] = N;
  for (int i = 1; i <= N; i++) {
    bool get_next = false;
    for (int ii = 30; ii <= 170; ii++)
      for (int jj = 30; jj <= 170; jj++) {
        if (dp[ii][jj] > 3) get_next = true;
        int val = (T < (dp[ii][jj] >> 2) ? T : (dp[ii][jj] >> 2));
        dp[ii - 1][jj] += val;
        dp[ii][jj - 1] += val;
        dp[ii + 1][jj] += val;
        dp[ii][jj + 1] += val;
        dp[ii][jj] -= val * 4;
      }
    if (!get_next) break;
  }
  for (int i = 1; i <= T; i++) {
    int L = 0, R = 0;
    scanf("%i%i", &L, &R);
    L += 100, R += 100;
    if (L <= 200 && L >= 0 && R <= 200 && R >= 0)
      printf("%i\n", dp[L][R]);
    else
      printf("0\n");
  }
  return 0;
}
