#include <bits/stdc++.h>
using namespace std;
struct Point {
  long long x, y;
  Point() {}
  Point(long long x0, long long y0) : x(x0), y(y0) {}
  void in() { scanf("%I64d %I64d", &x, &y); }
  long long operator*(Point pt) { return x * pt.y - y * pt.x; }
  Point operator-(Point pt) { return Point(x - pt.x, y - pt.y); }
  Point operator+(Point pt) { return Point(x + pt.x, y + pt.y); }
} p[1000010];
int n;
long long solve(Point o) {
  long long ans = 0;
  int i, j;
  i = j = 1;
  while (i <= n) {
    while (i == j || (p[j + 1] - p[i]) * (o - p[i]) >= 0) j++;
    ans += (long long)(j - i) * (j - i - 1) / 2;
    i++;
  }
  return ans;
}
bool In_Polygon(Point o) {
  for (int i = 1; i <= n; i++)
    if ((p[i + 1] - p[i]) * (o - p[i]) <= 0) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) p[i].in();
  for (int i = n + 1; i <= n + n; i++) p[i] = p[i - n];
  reverse(p + 1, p + n + n + 1);
  int cas;
  scanf("%d", &cas);
  for (int cc = 1; cc <= cas; cc++) {
    Point o;
    o.in();
    if (!In_Polygon(o))
      cout << 0 << endl;
    else
      cout << (long long)n * (n - 1) * (n - 2) / 6 - solve(o) << endl;
  }
  return 0;
}
