#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
};
const int N = 100000;
point a[N], b[N << 1];
long long cross(const point& a, const point& b) {
  return (long long)a.x * b.y - (long long)a.y * b.x;
}
bool operator<(const point& a, const point& b) {
  int part_a = (a.y > 0 || a.y == 0 && a.x >= 0);
  int part_b = (b.y > 0 || b.y == 0 && b.x >= 0);
  if (part_a != part_b) return part_a < part_b;
  return cross(a, b) > 0;
}
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d %d", &a[i].x, &a[i].y);
  scanf("%d", &m);
  while (m--) {
    int x, y;
    scanf("%d %d", &x, &y);
    for (int i = 0; i < n; ++i) {
      b[i].x = a[i].x - x;
      b[i].y = a[i].y - y;
    }
    sort(b, b + n);
    copy(b, b + n, b + n);
    bool found = false;
    for (int i = 0; i < n; ++i)
      if (cross(b[i], b[i + 1]) < 0) {
        found = true;
        break;
      }
    if (found) {
      cout << 0 << endl;
      continue;
    }
    long long ret = (long long)n * (n - 1) * (n - 2) / 6;
    for (int i = 0, j = 1; i < n; ++i) {
      while (j != i + n && cross(b[i], b[j]) > 0) ++j;
      long long k = j - i - 1;
      ret -= k * (k - 1) / 2;
    }
    cout << ret << endl;
  }
  return 0;
}
