#include <bits/stdc++.h>
using namespace std;
struct Pt {
  long long x, y;
  Pt operator+(const Pt& o) { return {x + o.x, y + o.y}; }
  Pt operator-(const Pt& o) { return {x - o.x, y - o.y}; }
};
long long cp(const Pt& a, const Pt& b) { return a.x * b.y - a.y * b.x; }
const int N = 100100;
Pt p[N];
int n;
long long choose3(long long x) { return x * (x - 1) * (x - 2) / 6; }
long long choose2(long long x) { return x * (x - 1) / 2; }
long long solve(long long _x, long long _y) {
  Pt ctr = {_x, _y};
  int j = 1;
  long long ans = choose3(n);
  for (int i = 0; i < n; ++i) {
    if (cp(p[(i + 1) % n] - p[i], ctr - p[i]) > 0) {
      return 0;
    }
    while (cp(p[(j + 1) % n] - p[i], ctr - p[i]) < 0) {
      ++j;
    }
    ans -= choose2(j - i);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> p[i].x >> p[i].y;
  }
  int TT;
  cin >> TT;
  while (TT--) {
    int x, y;
    cin >> x >> y;
    long long ans = solve(x, y);
    cout << ans << "\n";
  }
  return 0;
}
