#include <bits/stdc++.h>
using namespace std;
long long dot(pair<long long, long long> a, pair<long long, long long> b,
              pair<long long, long long> c) {
  pair<long long, long long> u = {b.first - a.first, b.second - a.second};
  pair<long long, long long> v = {c.first - a.first, c.second - a.second};
  return u.first * v.first + u.second * v.second;
}
long long cross(pair<long long, long long> a, pair<long long, long long> b,
                pair<long long, long long> c) {
  pair<long long, long long> u = {b.first - a.first, b.second - a.second};
  pair<long long, long long> v = {c.first - a.first, c.second - a.second};
  return u.first * v.second - u.second * v.first;
}
bool inside(vector<pair<long long, long long> > &v,
            pair<long long, long long> p) {
  int n = v.size(), start = 0;
  for (int i = 1; i < n; i++) {
    if (v[i].first < v[start].first ||
        (v[i].first == v[start].first && v[i].second < v[start].second))
      start = i;
  }
  rotate(v.begin(), v.begin() + start, v.end());
  if (cross(v[0], v[1], p) < 0) return false;
  if (cross(v[0], v[n - 1], p) > 0) return false;
  int l = 1, r = n - 2;
  while (l < r) {
    int m = (l + r + 1) / 2;
    if (cross(v[0], v[m], p) >= 0)
      l = m;
    else
      r = m - 1;
  }
  long long st = abs(cross(v[0], v[l], v[l + 1]));
  long long s1 = abs(cross(p, v[0], v[l]));
  long long s2 = abs(cross(p, v[l], v[l + 1]));
  long long s3 = abs(cross(p, v[l + 1], v[0]));
  if (st == s1 + s2 + s3) return true;
  return false;
}
long long f3(long long first) {
  return (first * (first - 1) * (first - 2)) / 6;
}
long long f2(long long first) { return (first * (first - 1)) / 2; }
long long solve(vector<pair<long long, long long> > &v,
                pair<long long, long long> p) {
  if (!inside(v, p)) {
    return 0;
  }
  int n = v.size();
  long long all = f3(n), cnt = 0;
  for (int pos = 0; pos < n; pos++) {
    int l = 1, r = n - 2;
    while (l < r) {
      int m = (r + l + 1) / 2;
      if (cross(v[pos], v[(pos + m) % n], p) >= 0)
        l = m;
      else
        r = m - 1;
    }
    cnt += f2(l) + f2(n - l - 1);
  }
  return all - (cnt / 2);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, t;
  cin >> n;
  vector<pair<long long, long long> > v(n);
  for (int i = 0; i < n; i++) cin >> v[i].first >> v[i].second;
  reverse(v.begin(), v.end());
  cin >> t;
  for (int i = 0; i < t; i++) {
    pair<long long, long long> p;
    cin >> p.first >> p.second;
    cout << solve(v, p) << "\n";
  }
  return 0;
}
