#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:20000000")
string problem_name = "a";
void init() { freopen((problem_name + ".in").c_str(), "rt", stdin); }
struct tpoint {
  int x, y;
};
long long vp(tpoint a, tpoint b, tpoint c) {
  tpoint f, s;
  f.x = b.x - a.x;
  f.y = b.y - a.y;
  s.x = c.x - a.x;
  s.y = c.y - a.y;
  return f.x * (long long)s.y - (long long)f.y * s.x;
}
tpoint mas[100111];
int main() {
  int n, t;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d", &mas[i].x, &mas[i].y);
  int p = 1;
  scanf("%d", &t);
  while (t--) {
    tpoint c;
    long long res = 0;
    scanf("%d%d", &c.x, &c.y);
    p = 1;
    bool ok = 1;
    for (int i = 0; i < n; i++) {
      if (vp(mas[i], mas[(i + 1) % n], c) >= 0) ok = 0;
    }
    if (ok)
      for (int i = 0; i < n; i++) {
        if (p == i) p++;
        if (p >= n) p = 0;
        while (vp(mas[i], mas[p], c) < 0) {
          p++;
          if (p == n) p = 0;
        }
        p--;
        if (p < 0) p = n - 1;
        long long col = p - i + 1;
        if (col <= 0) col += n;
        if (col > 2) {
          col--;
          res += col * (col - 1) / 2;
        }
      }
    if (!ok)
      res = 0;
    else
      res = (long long)n * (n - 1) * (n - 2) / 6 - res;
    cout << res << endl;
  }
  return 0;
}
