#include <bits/stdc++.h>
using namespace std;
vector<int> c[111111];
int vmin[111111], vmax[111111], anc[20][111111];
long long x[111111], y[111111], v1, v2;
int p[111111];
int N, M, i, j, idx;
void DFS(int x) {
  int z;
  idx++;
  vmin[x] = idx;
  for (z = 0; z < c[x].size(); z++) DFS(c[x][z]);
  vmax[x] = idx;
}
int LCA(int x, int y) {
  if (vmin[x] <= vmin[y] && vmin[y] <= vmax[x]) return x;
  for (i = 20 - 1; i >= 0; i--) {
    j = anc[i][x];
    if (vmin[y] < vmin[j] || vmin[y] > vmax[j]) x = j;
  }
  return p[x];
}
int main() {
  scanf("%d", &N);
  for (i = 1; i <= N; i++) scanf("%I64d %I64d", &(x[i]), &(y[i]));
  p[N] = 0;
  p[N - 1] = N;
  for (i = N - 2; i >= 1; i--) {
    p[i] = i + 1;
    j = i + 1;
    while (j < N) {
      v1 = y[i] * (x[p[j]] - x[i]) + (x[j] - x[i]) * (y[p[j]] - y[i]);
      v2 = y[j] * (x[p[j]] - x[i]);
      if (v1 > v2) {
        if (0) fprintf(stderr, "i=%d: %d visible\n", i, p[j]);
        p[i] = p[j];
        j = p[j];
      } else
        break;
    }
  }
  for (i = 1; i < N; i++) anc[0][i] = p[i];
  anc[0][N] = N;
  for (j = 1; j < 20; j++)
    for (i = 1; i <= N; i++) anc[j][i] = anc[j - 1][anc[j - 1][i]];
  for (i = 1; i < N; i++) c[p[i]].push_back(i);
  idx = 0;
  DFS(N);
  scanf("%d", &M);
  while (M--) {
    scanf("%d %d", &i, &j);
    printf("%d", LCA(i, j));
    if (M > 0) printf(" ");
  }
  printf("\n");
  return 0;
}
