#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> points;
vector<pair<long long, long long> > vertex;
long long right(pair<long long, long long> &a, pair<long long, long long> &b,
                pair<long long, long long> &c) {
  return (a.first - c.first) * (b.second - a.second) -
         (a.first - b.first) * (c.second - a.second);
}
signed main() {
  long long n, t;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long a, b;
    cin >> a >> b;
    vertex.push_back(make_pair(a, b));
  }
  vertex.push_back(make_pair(vertex[0].first, vertex[0].second));
  cin >> t;
  long long j;
  while (t--) {
    long long res = (n - 1) * (n - 2) * n / 6;
    cin >> points.first >> points.second;
    j = 1;
    for (long long i = 0; i < n; i++) {
      if (right(points, vertex[i], vertex[i + 1]) > 0) {
        res = 0;
        break;
      }
      while (right(points, vertex[i], vertex[j]) < 0) {
        j = (j + 1) % n;
      }
      long long k = (n + i - j - 1) % n;
      res -= (k + 1) * k / 2;
    }
    cout << res << "\n";
  }
}
