#include <bits/stdc++.h>
using namespace std;
long long x, y;
long long cruz(long long x1, long long y1, long long x2, long long y2) {
  pair<long long, long long> bv = {x - x2, y - y2};
  pair<long long, long long> av = {x1 - x2, y1 - y2};
  return av.first * bv.second - av.second * bv.first < 0;
}
long long cruzV(long long x1, long long y1, long long x2, long long y2) {
  pair<long long, long long> av = {x - x1, y - y1};
  pair<long long, long long> bv = {x2 - x1, y2 - y1};
  return av.first * bv.second - av.second * bv.first > 0;
}
long long solve(int i, vector<pair<long long, long long>>& a) {
  int n = a.size();
  int l = i, r = i + n / 2 - 1;
  int m = (l + r) / 2;
  while (l < r) {
    m = (l + r) / 2;
    if (cruz(a[m].first, a[m].second, a[i].first, a[i].second)) {
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  int inx = 0;
  for (int j = max(l - 3, i); j <= min(r + 3, i + n / 2 - 1); j++) {
    if (cruz(a[j].first, a[j].second, a[i].first, a[i].second)) {
      inx = j;
    }
  }
  long long dots = inx - i;
  if (dots <= 1) return 0ll;
  long long ans = dots;
  ans *= (dots - 1);
  ans /= 2ll;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  ;
  int n;
  cin >> n;
  vector<pair<long long, long long>> a(2 * n);
  for (int i = 0; i < n; i++) {
    long long xc, yc;
    cin >> xc >> yc;
    a[i] = {xc, yc};
    a[i + n] = a[i];
  }
  int t;
  cin >> t;
  long long ans = n * 1ll;
  ans *= (n - 1ll);
  ans *= (n - 2ll);
  ans /= 6ll;
  long long total = ans;
  while (t--) {
    cin >> x >> y;
    ans = total;
    for (int i = 0; i < n; i++) ans -= solve(i, a);
    bool f = true;
    for (int i = 0; i < n; i++)
      f &= cruzV(a[i].first, a[i].second, a[i + 1].first, a[i + 1].second);
    cout << (f ? ans : 0) << endl;
  }
  return 0;
}
