#include <bits/stdc++.h>
using namespace std;
long long int arrx[100002], arry[100002], arr[100002], p = 0;
int par[20][100002], lev[100002];
bool check(int a, int b, int c) {
  long long int ans = (arry[c] - arry[b]) * (arrx[b] - arrx[a]);
  ans = ans - (arrx[c] - arrx[b]) * (arry[b] - arry[a]);
  return (ans > 0);
}
void pre(int n) {
  int i, j;
  for (i = 1; i < 20; i++)
    for (j = 1; j <= n; j++) par[i][j] = par[i - 1][par[i - 1][j]];
}
int lca(int a, int b) {
  if (lev[a] > lev[b]) swap(a, b);
  int diff = lev[b] - lev[a], i;
  for (i = 19; i >= 0; i--)
    if (diff & (1 << i)) b = par[i][b];
  if (a == b) return a;
  for (i = 19; i >= 0; i--) {
    if (par[i][a] != par[i][b]) {
      a = par[i][a];
      b = par[i][b];
    }
  }
  return par[0][b];
}
int main() {
  int n, i;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%lld%lld", &arrx[i], &arry[i]);
  arr[p++] = n;
  lev[n] = 0;
  for (i = n - 1; i >= 1; i--) {
    while (p > 1 && check(i, arr[p - 1], arr[p - 2])) p--;
    par[0][i] = arr[p - 1];
    lev[i] = lev[arr[p - 1]] + 1;
    arr[p++] = i;
  }
  pre(n);
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d ", lca(a, b));
  }
  return 0;
}
