#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
};
double cross(point a, point b, point c, point d) {
  double x1 = b.x - a.x, y1 = b.y - a.y, x2 = d.x - c.x, y2 = d.y - c.y;
  return x1 * y2 - x2 * y1;
}
point p[200001];
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d", &p[i].x, &p[i].y);
    p[n + i] = p[i];
  }
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d", &p[0].x, &p[0].y);
    bool flag = true;
    for (int i = 1; i <= n; ++i) {
      if (cross(p[i], p[i + 1], p[i], p[0]) >= 0) {
        flag = false;
        break;
      }
    }
    if (!flag) {
      printf("0\n");
      continue;
    }
    int j = 1, k = 2;
    long long ans = (long long)n * (n - 1) * (n - 2) / 6;
    while (j <= n) {
      while (cross(p[j], p[k + 1], p[j], p[0]) < 0) ++k;
      ans -= (long long)(k - j) * (k - j - 1) / 2;
      ++j;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
