#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
struct ww {
  double x, y;
  inline ww operator-(const ww &A) { return (ww){x - A.x, y - A.y}; }
  inline double operator*(const ww &A) { return x * A.y - y * A.x; }
} a[100010], O;
int i, j, k, n, m, T, te, x, y;
double b[100010];
inline bool ju(ww a, ww b, ww c) {
  return ((O - a) * (b - a)) > 0 && ((c - a) * (O - a)) > 0 &&
         ((O - b) * (c - b)) > 0;
}
inline long long get(int x, int y) {
  long long len;
  if (y > x)
    len = y - x;
  else
    len = n - x + y;
  return len * (len - 1) / 2;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    a[i].x = x, a[i].y = y;
  }
  scanf("%d", &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    O.x = x, O.y = y;
    int F = 0;
    for (j = 3; j <= n; j++)
      if (ju(a[1], a[j - 1], a[j])) {
        F = 1;
        break;
      }
    if (!F) {
      printf("0\n");
      continue;
    }
    long long an = 0;
    int u = j - 1;
    for (k = 1; k <= n; k++) {
      an += get(k, u) + get(j, k);
      if (k == n) break;
      for (; !ju(a[k + 1], a[u], a[j]);) {
        u++;
        if (u > n) u -= n;
        j++;
        if (j > n) j -= n;
      }
    }
    an = 1ll * n * (n - 1) * (n - 2) / 6 - an / 2;
    printf("%I64d\n", an);
  }
  return 0;
}
