#include <bits/stdc++.h>
struct P {
  long long x, y;
  P(long long x = 0, long long y = 0) : x(x), y(y) {}
  P operator-(const P& b) { return P(x - b.x, y - b.y); }
  long long operator*(const P& b) { return x * b.y - y * b.x; }
} pt[102000], s;
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%I64d%I64d", &pt[i].x, &pt[i].y);
  }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%I64d%I64d", &s.x, &s.y);
    long long sum = 0;
    long long r = 0;
    for (int j = 0; j < n; j++) {
      while (r < j + n && (pt[r % n] - pt[j]) * (s - pt[j]) <= 0) r++;
      if (r == j + n) {
        sum = 0;
        break;
      }
      r--;
      long long a = r - j, b = n - 1 - a;
      sum += a * b - b * (b - 1) / 2;
    }
    printf("%I64d\n", sum / 3);
  }
}
