#include <bits/stdc++.h>
using namespace std;
long long n, all;
struct dot {
  long long x, y;
  dot(long long x = 0, long long y = 0) : x(x), y(y){};
  friend istream &operator>>(istream &in, dot &a) {
    in >> a.x >> a.y;
    return in;
  }
};
bool ok(dot a, dot b, dot p) {
  dot n(b.y - a.y, a.x - b.x);
  dot pp(p.x - a.x, p.y - a.y);
  return n.x * pp.x + n.y * pp.y > 0;
}
dot pnt[100001];
long long count(const dot &p) {
  long long cnt = 0;
  for (int a = 0; a < n; a++) {
    long long l = 1, r = n - 1;
    while (l != r - 1) {
      int mid = (l + r) / 2;
      int b = (a + mid) % n;
      if (ok(pnt[a], pnt[b], p))
        l = mid;
      else
        r = mid;
    }
    cnt += (l * (l - 1)) / 2;
  }
  return all - cnt;
}
bool vect(dot p, dot a, dot b) {
  dot aa(a.x - p.x, a.y - p.y);
  dot bb(b.x - p.x, b.y - p.y);
  return aa.x * bb.y - aa.y * bb.x < 0;
}
bool inn(const dot &p) {
  for (int i = 0; i < n; i++) {
    int i1 = i, i2 = (i + 1) % n;
    if (!vect(p, pnt[i1], pnt[i2])) return false;
  }
  return true;
}
int main() {
  cin >> n;
  all = n * (n - 1) * (n - 2) / 6;
  for (int i = 0; i < n; i++) cin >> pnt[i];
  int t;
  cin >> t;
  while (t--) {
    dot p;
    cin >> p;
    cout << (inn(p) ? count(p) : 0) << '\n';
  }
  return 0;
}
