#include <bits/stdc++.h>
using namespace std;
double PI = acos(-1);
double EPS = 1e-7;
int INF = 1000000000;
int MOD = 1000000007;
int MAXINT = 2147483647;
long long INFLL = 1000000000000000000LL;
long long MAXLL = 9223372036854775807LL;
int mx[8] = {-1, 1, 0, 0, -1, -1, 1, 1};
int my[8] = {0, 0, -1, 1, -1, 1, -1, 1};
pair<long long, long long> p[100005];
int nx[100005];
int dph[100005];
int par[100005][18];
void add(int first, int p) {
  dph[first] = dph[p] + 1;
  par[first][0] = p;
  for (int(a) = (1); (a) <= (17); (a)++) {
    par[first][a] = par[par[first][a - 1]][a - 1];
  }
}
int lca(int first, int second) {
  if (dph[first] > dph[second]) swap(first, second);
  int dif = dph[second] - dph[first];
  for (int(a) = (17); (a) >= (0); (a)--) {
    if (dif & (1 << a)) second = par[second][a];
  }
  if (first == second) return first;
  for (int(a) = (17); (a) >= (0); (a)--) {
    if (par[first][a] && par[second][a] && par[first][a] != par[second][a]) {
      first = par[first][a];
      second = par[second][a];
    }
  }
  return par[first][0];
}
long long cross(pair<long long, long long> O, pair<long long, long long> A,
                pair<long long, long long> B) {
  return (A.first - O.first) * (B.second - O.second) -
         (A.second - O.second) * (B.first - O.first);
}
int lo[100005];
int con[100005];
int main() {
  int n;
  scanf("%d", &n);
  for (int(a) = (1); (a) <= (n); (a)++) {
    scanf("%I64d%I64d", &p[a].first, &p[a].second);
  }
  int clo = 0;
  for (int(a) = (n); (a) >= (1); (a)--) {
    while (clo >= 2 && cross(p[lo[clo - 1]], p[lo[clo]], p[a]) < 0) {
      clo--;
    }
    nx[a] = lo[clo];
    lo[++clo] = a;
  }
  for (int(a) = (1); (a) <= (clo); (a)++) {
    con[lo[a]] = 1;
  }
  for (int(a) = (n - 1); (a) >= (1); (a)--) {
    add(a, nx[a]);
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int u, v;
    scanf("%d%d", &u, &v);
    printf("%d\n", lca(u, v));
  }
}
