#include <bits/stdc++.h>
using namespace std;
const int moves[][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
const int maxN = 100005;
class Point {
 public:
  Point() {}
  Point(long long x, long long y) {
    this->x = x;
    this->y = y;
  }
  long long x, y;
  void read() { scanf("%I64d%I64d", &x, &y); }
};
long long VP(Point A, Point B, Point C) {
  long long x1 = B.x - A.x, y1 = B.y - A.y;
  long long x2 = C.x - A.x, y2 = C.y - A.y;
  long long VP = x1 * y2 - x2 * y1;
  if (VP > 0) return 1;
  if (VP == 0) return 0;
  return -1;
}
Point a[maxN];
long long n;
bool inPolygon(Point p) {
  a[n] = a[0];
  for (long long i = 0; i < n; i++) {
    if (VP(a[i], p, a[i + 1]) < 0LL) return false;
  }
  return true;
}
long long solve(Point p) {
  if (!inPolygon(p)) return 0;
  long long sol = n * (n - 1LL) * (n - 2LL) / 6LL;
  long long j = 1;
  for (int i = 0; i < n; i++) {
    while (VP(a[i], p, a[j]) > 0) j = (j + 1) % n;
    long long levo = j - i - 1;
    if (levo < 0) levo += n;
    sol -= levo * (levo - 1LL) / 2LL;
  }
  return sol;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) a[i].read();
  int t;
  cin >> t;
  while (t--) {
    Point p;
    p.read();
    cout << solve(p) << endl;
  }
  return 0;
}
