#include <bits/stdc++.h>
using namespace std;
struct Point {
  long long x, y;
};
Point a[100005];
int n;
long long lf[100005], lr[100005], sum[100005];
int op(Point a, Point o, Point b) {
  long long x1 = o.x - a.x, y1 = o.y - a.y;
  long long x2 = b.x - o.x, y2 = b.y - o.y;
  if (x1 * y2 - x2 * y1 < 0)
    return 1;
  else
    return -1;
}
void deal(Point in) {
  long long ans = 0;
  sum[0] = 0;
  for (int i = 1; i <= n - 1; i++) {
    int l = i, h = n;
    while (l != h) {
      int mid = (l + h) / 2 + 1;
      if (op(a[i], in, a[mid]) < 0)
        l = mid;
      else
        h = mid - 1;
    }
    lf[i] = l - i;
    sum[i] = sum[i - 1] + lf[i];
  }
  sum[n] = sum[n - 1];
  lf[n] = 0;
  for (int i = 1; i <= n - 2; i++) {
    long long tmp = sum[i + lf[i]] - sum[i] - (lf[i] - 1) * lf[i] / 2;
    ans = ans + tmp;
  }
  printf("%I64d\n", ans);
}
bool dl(Point in) {
  long long x1 = in.x - a[n].x, y1 = in.y - a[n].y;
  long long x2 = in.x - a[1].x, y2 = in.y - a[1].y;
  long long dr = x1 * y2 - x2 * y1;
  for (int i = 1; i < n; i++) {
    long long tx1 = in.x - a[i].x, ty1 = in.y - a[i].y;
    long long tx2 = in.x - a[i + 1].x, ty2 = in.y - a[i + 1].y;
    long long tdr = tx1 * ty2 - tx2 * ty1;
    if ((tdr < 0 && dr > 0) || (tdr > 0 && dr < 0)) return true;
  }
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d%I64d", &a[i].x, &a[i].y);
  int t;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    Point in;
    scanf("%I64d%I64d", &in.x, &in.y);
    if (dl(in)) {
      printf("0\n");
      continue;
    }
    deal(in);
  }
}
