#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, nTest;
struct Point {
  int x, y;
  Point(int _x = 0, int _y = 0) : x(_x), y(_y) {}
  Point operator-(const Point &_) const { return Point(x - _.x, y - _.y); }
  ll operator^(const Point &_) const { return 1LL * x * _.y - 1LL * y * _.x; }
} p;
vector<Point> pol;
int nxt(int _i, int _n) { return _i == _n - 1 ? 0 : _i + 1; }
void Main() {
  int x, y;
  scanf("%d %d", &x, &y);
  p = Point(x, y);
  ll ans = 0;
  bool check = 1;
  for (int i = 0; i < n; ++i) {
    int j = nxt(i, n);
    if (((p - pol[i]) ^ (pol[j] - pol[i])) < 0) {
      check = 0;
      break;
    }
  }
  if (!check) {
    printf("0\n");
    return;
  }
  for (int i = 0, j = 1; i < n; ++i) {
    while (((p - pol[i]) ^ (pol[j] - pol[i])) > 0) j = nxt(j, n);
    int tmp = ((j - 2 - i) % n + n) % n;
    ans += 1LL * tmp * (tmp + 1) / 2;
  }
  printf("%I64d\n", 1LL * n * (n - 1) * (n - 2) / 6 - ans);
}
int main() {
  scanf("%d", &n);
  pol.assign(n, Point());
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    pol[i] = Point(x, y);
  }
  scanf("%d", &nTest);
  while (nTest--) Main();
  return 0;
}
