#include <bits/stdc++.h>
using namespace std;
int rd() { return RAND_MAX == 32767 ? ((rand() << 15) ^ rand()) : rand(); }
const int maxn = 100010;
struct Point {
  int x, y;
} p[maxn];
long long Cross(Point p0, Point p1, Point p2) {
  return (long long)(p1.x - p0.x) * (p2.y - p0.y) -
         (long long)(p1.y - p0.y) * (p2.x - p0.x);
}
int main() {
  int n, m;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> p[i].x >> p[i].y;
  cin >> m;
  for (int o = 0; o < m; o++) {
    Point p0;
    cin >> p0.x >> p0.y;
    int inside = 1;
    for (int i = 0; i < n; i++)
      if (Cross(p[i], p[(i + 1) % n], p0) > 0) {
        inside = 0;
        break;
      }
    if (!inside) {
      cout << 0 << endl;
      continue;
    }
    int k = 0;
    long long res = (long long)n * (n - 1) * (n - 2) / 6;
    for (int i = 0, k = 0; i < n; i++) {
      for (; (k + 1) % n != i && Cross(p[i], p[(k + 1) % n], p0) < 0;
           k = (k + 1) % n)
        ;
      if (i != k && (i + 1) % n != k) {
        int N = k - i + 1;
        if (N <= 0) N += n;
        res -= (long long)(N - 1) * (N - 2) / 2;
      }
      if (k == i) k = (k + 1) % n;
    }
    cout << res << endl;
  }
  return 0;
}
