#include <bits/stdc++.h>
using namespace std;
long long cross(pair<int, int> a, pair<int, int> b) {
  return 1LL * a.first * b.second - 1LL * a.second * b.first;
}
long long ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
  pair<int, int> p = pair<int, int>(b.first - a.first, b.second - a.second);
  pair<int, int> q = pair<int, int>(c.first - a.first, c.second - a.second);
  return cross(p, q);
}
int N, Q;
pair<int, int> P[100010];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &P[i].first, &P[i].second);
  }
  scanf("%d", &Q);
  for (int q = 0; q < Q; q++) {
    int x, y;
    scanf("%d %d", &x, &y);
    bool out = false;
    for (int i = 0; i < N; i++) {
      int j = (i + 1) % N;
      if (ccw(pair<int, int>(x, y), P[i], P[j]) >= 0) {
        out = true;
        break;
      }
    }
    if (out) {
      printf("0\n");
      continue;
    }
    long long ans = 1LL * N * (N - 1) * (N - 2) / 6;
    int pos = 0;
    for (int i = 0; i < N; i++) {
      while (ccw(P[i], P[pos], pair<int, int>(x, y)) <= 0) pos = (pos + 1) % N;
      int n = (pos - i + N) % N - 1;
      ans -= 1LL * n * (n - 1) / 2;
    }
    printf("%lld\n", ans);
  }
}
