#include <bits/stdc++.h>
using namespace std;
struct pv {
  int x, y;
  pv() {}
  pv(int a, int b) {
    x = a;
    y = b;
  }
  pv operator-(pv other) { return pv(x - other.x, y - other.y); }
  long long int operator^(pv other) {
    return (long long int)x * other.y - (long long int)y * other.x;
  }
};
int n;
pv v[1000010];
long long int tot;
void update(int &j, int &sz, int val) {
  j += val;
  sz += val;
  if (j == n + 1) j = 1;
  if (j == 0) j = n;
}
long long int get(int sz) {
  if (sz < 2) return 0;
  return ((long long int)sz * (sz - 1)) / 2;
}
long long int solve(pv p) {
  int j = 2, sz = 2;
  long long int fora = 0LL;
  v[n + 1] = v[1];
  bool entrou;
  for (int i = 1; i <= n; i++, sz--) {
    if (i == j) update(j, sz, 1);
    entrou = false;
    while (((p - v[i]) ^ (v[j] - v[i])) > 0) {
      update(j, sz, 1);
      entrou = true;
    }
    if (entrou) update(j, sz, -1);
    fora += get(sz - 1);
    if (((v[i] - p) ^ (v[i + 1] - p)) > 0) return 0;
  }
  return tot - fora;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d %d", &v[i].x, &v[i].y);
  tot = ((long long int)n * (n - 1) * (n - 2)) / 6;
  int q, x, y;
  scanf("%d", &q);
  while (q--) {
    scanf("%d %d", &x, &y);
    printf("%lld\n", solve(pv(x, y)));
  }
  return 0;
}
