#include <bits/stdc++.h>
using namespace std;
const int MaxN = 200005;
long long x[MaxN], y[MaxN];
int main() {
  int n, T;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%I64d%I64d", &x[i], &y[i]);
    x[i + n] = x[i];
    y[i + n] = y[i];
  }
  scanf("%d", &T);
  while (T--) {
    long long xx, yy;
    scanf("%I64d%I64d", &xx, &yy);
    long long tot = (long long)n * (n - 1) * (n - 2) / 6;
    int p = 0, ok = 1;
    for (int i = 0; i < n; i++) {
      if ((x[i + 1] - x[i]) * (yy - y[i]) - (y[i + 1] - y[i]) * (xx - x[i]) >=
          0)
        ok = 0;
      while ((xx - x[i]) * (y[p + 1] - y[i]) - (yy - y[i]) * (x[p + 1] - x[i]) >
             0)
        p++;
      long long t = p - i;
      if (t >= 2) tot -= t * (t - 1) / 2;
    }
    printf("%I64d\n", ok ? tot : 0);
  }
  return 0;
}
