#include <bits/stdc++.h>
using namespace std;
inline void read() {}
template <typename T, typename... Ts>
inline void read(T& A, Ts&... As) {
  T x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  A = x * f, read(As...);
}
inline void write(char a) { putchar(a); }
template <typename T>
inline void write(T a) {
  if (a < 0ll) putchar('-'), a = -a;
  if (a > 9ll) write(a / 10ll);
  putchar(a % 10ll + '0');
}
template <typename T, typename... Ts>
inline void write(T A, Ts... As) {
  write(A), write(As...);
}
const int N = 200010;
int n, q;
pair<double, double> mius(pair<double, double> x, pair<double, double> y) {
  return pair<double, double>(x.first - y.first, x.second - y.second);
}
double mult(pair<double, double> x, pair<double, double> y) {
  return (x.first * y.second - x.second * y.first);
}
pair<double, double> a[N], x;
long long ans;
int chkout() {
  for (register int i = 1; i <= n; ++i) {
    if (mult(mius(a[i], x), mius(a[i + 1], x)) >= 0) return 1;
  }
  return 0;
}
signed main() {
  read(n);
  for (register int i = 1; i <= n; ++i)
    cin >> a[i].first >> a[i].second, a[i + n] = a[i];
  read(q);
  while (q--) {
    cin >> x.first >> x.second, ans = (n * (n - 1ll) * (n - 2ll)) / 6ll;
    if (chkout()) {
      puts("0");
      continue;
    }
    long long j = 1, num = 0;
    for (register int i = 1; i <= n; ++i) {
      if (i != 1) --num;
      while (mult(mius(a[i], x), mius(a[j], x)) <= 0) {
        if (j != i) ++num;
        j %= n, ++j;
      }
      ans -= (num * (num - 1ll) / 2ll);
    }
    write(ans, '\n');
  }
  return 0;
}
