#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
  point(long long x1 = 0, long long y1 = 0) {
    x = x1;
    y = y1;
  }
  point operator-(const point &a) const { return point(x - a.x, y - a.y); }
};
bool isconv(point a, point b, point c) {
  long long cross = (b - a).x * (c - a).y - (b - a).y * (c - a).x;
  if (cross <= 0) {
    return true;
  } else {
    return false;
  }
}
long long s[100005], level[100005], depth[32][100005], size = 0, n;
point input[100005];
int lca(int a, int b) {
  if (level[a] > level[b]) {
    swap(a, b);
  }
  int d = level[b] - level[a];
  for (int i = 0; i < 19; i++) {
    if (d & (1 << i)) {
      b = depth[i][b];
    }
  }
  if (a == b) {
    return a;
  }
  for (int i = 19 - 1; i >= 0; i--) {
    if (depth[i][a] != depth[i][b]) {
      a = depth[i][a];
      b = depth[i][b];
    }
  }
  return depth[0][a];
}
int main() {
  int x, y;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%I64d%I64d", &input[i].x, &input[i].y);
  }
  depth[0][n - 1] = n - 1;
  s[++size] = n - 1;
  level[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    while (size >= 2 &&
           isconv(input[i], input[s[size]], input[s[size - 1]]) == false) {
      size--;
    }
    depth[0][i] = s[size];
    level[i] = level[s[size]] + 1;
    s[++size] = i;
  }
  for (int i = 1; i < 19; i++) {
    for (int j = 0; j < n; j++) {
      depth[i][j] = depth[i - 1][depth[i - 1][j]];
    }
  }
  cin >> n;
  while (n--) {
    scanf("%d%d", &x, &y);
    printf("%d ", lca(x - 1, y - 1) + 1);
  }
}
