#include <bits/stdc++.h>
using namespace std;
vector<long long> X;
vector<long long> Y;
signed main() {
  long long N;
  cin >> N;
  for (long long i = 0; i < N; i++) {
    long long x, y;
    cin >> x >> y;
    X.push_back(x);
    Y.push_back(y);
  }
  for (long long i = 0; i < N; i++) {
    X.push_back(X[i]);
    Y.push_back(Y[i]);
  }
  long long real_area = 0;
  for (long long i = 0; i < N; i++) {
    real_area += (X[i + 1] - X[i]) * (Y[i] + Y[i + 1]);
  }
  real_area = abs(real_area);
  long long Test;
  cin >> Test;
  for (long long T = 0; T < Test; T++) {
    long long a, b;
    cin >> a >> b;
    long long s = 0;
    for (long long i = 0; i < N; i++) {
      s += abs(a * Y[i] + X[i] * Y[i + 1] + X[i + 1] * b - b * X[i] -
               X[i + 1] * Y[i] - a * Y[i + 1]);
    }
    s = abs(s);
    if (s > real_area) {
      cout << "0\n";
      continue;
    }
    long long L = 0, R = 1, Ans = 0;
    while (L < N) {
      if (L == R) R++;
      while ((Y[R] - Y[L]) * (a - X[L]) > (X[R] - X[L]) * (b - Y[L])) R++;
      R--;
      Ans += (R - L) * (R - L - 1) / 2;
      L++;
    }
    cout << N * (N - 1) * (N - 2) / 6 - Ans << '\n';
  }
}
