#include <bits/stdc++.h>
int n;
struct point {
  int x, y;
};
point p, v[100005];
long long total;
int semn(point p1, point p2, point p3) {
  long long s;
  s = ((long long)p2.x - p1.x) * ((long long)p3.y - p2.y) -
      ((long long)p2.y - p1.y) * ((long long)p3.x - p2.x);
  if (s < 0) return -1;
  if (s > 0) return 1;
  return 0;
}
int ok(int i, int j, int k) {
  int s1 = semn(v[i], v[j], p);
  int s2 = semn(v[j], v[k], p);
  int s3 = semn(v[k], v[i], p);
  return s1 == s2 && s2 == s3;
}
void rez() {
  int i, j;
  long long nr = 0, nr1, nr2;
  j = 2;
  for (i = 1; i <= n; i++) {
    while (!ok(i, (j - 1) % n + 1, (j + 1 - 1) % n + 1)) j++;
    nr1 = j - i;
    nr2 = n - nr1 - 1;
    nr = nr + nr1 * (nr1 - 1) / 2 + nr2 * (nr2 - 1) / 2;
  }
  total -= nr / 2;
}
int polig() {
  int s = semn(v[1], v[2], p);
  int i;
  for (i = 1; i <= n; i++)
    if (s != semn(v[i], v[(i - 1 + 1) % n + 1], p)) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  int i, t;
  for (i = 1; i <= n; i++) scanf("%d %d", &v[i].x, &v[i].y);
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d", &p.x, &p.y);
    if (!polig()) {
      printf("0\n");
      continue;
    }
    total = (long long)n * (n - 1) * (n - 2) / 6;
    rez();
    printf("%I64d\n", total);
  }
  return 0;
}
