#include <bits/stdc++.h>
using namespace std;
struct Point {
  int x, y;
};
inline Point operator-(const Point& p, const Point& q) {
  Point r;
  r.x = p.x - q.x;
  r.y = p.y - q.y;
  return r;
}
inline long long cp(const Point& p, const Point& q) {
  return (long long)p.x * q.y - (long long)q.x * p.y;
}
const int N = 200003;
Point p[N];
int n;
bool inPoly(const Point& q) {
  for (int i = 0; i < n; ++i)
    if (cp(q - p[i], p[i + 1] - p[i]) <= 0) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d%d", &p[i].x, &p[i].y);
  for (int i = n; i < 2 * n; ++i) p[i] = p[i - n];
  int t;
  scanf("%d", &t);
  while (t--) {
    Point q;
    scanf("%d%d", &q.x, &q.y);
    if (!inPoly(q)) {
      puts("0");
      continue;
    }
    long long res = (long long)n * (n - 1) * (n - 2) / 6;
    for (int i = 0, j = 2; i < n; ++i) {
      while (cp(q - p[i], p[j] - p[i]) > 0) ++j;
      int x = j - i - 1;
      res -= (long long)x * (x - 1) / 2;
    }
    printf("%lld\n", res);
  }
  return 0;
}
