#include <bits/stdc++.h>
using namespace std;
struct point {
  int id;
  long long int x, y;
  bool operator<(point a) const {
    if (x != a.x) return x < a.x;
    return y < a.y;
  }
  point operator-(point a) {
    point k;
    k.x = x - a.x;
    k.y = y - a.y;
    return k;
  }
  long long int operator*(point a) { return x * a.y - y * a.x; }
};
int n, q, n1, n2, uh = -1, dp[100010][20], prof[100010];
vector<point> v, upper_hull;
vector<int> grafo[100010];
void DFS(int i, int p) {
  int tam = grafo[i].size();
  for (int g = 0; g < tam; g++) {
    int prox = grafo[i][g];
    if (prox == p) continue;
    dp[prox][0] = i;
    prof[prox] = prof[i] + 1;
    DFS(prox, i);
  }
}
int LCA(int i, int j) {
  if (prof[i] < prof[j]) swap(i, j);
  int d = prof[i] - prof[j];
  for (int g = 0; g < 20; g++)
    if (d & (1 << g)) i = dp[i][g];
  if (i == j) return i;
  for (int g = 20 - 1; g >= 0; g--) {
    if (dp[i][g] != dp[j][g]) {
      i = dp[i][g];
      j = dp[j][g];
    }
  }
  return dp[i][0];
}
int main() {
  scanf("%d", &n);
  for (int g = 1; g <= n; g++) {
    point k;
    k.id = g;
    scanf("%lld %lld", &k.x, &k.y);
    v.push_back(k);
  }
  for (int g = n - 1; g >= 0; g--) {
    while (uh >= 1 &&
           (upper_hull[uh] - upper_hull[uh - 1]) * (v[g] - upper_hull[uh - 1]) <
               0) {
      upper_hull.pop_back();
      uh--;
    }
    upper_hull.push_back(v[g]);
    uh++;
    if (g != n - 1) {
      grafo[upper_hull[uh].id].push_back(upper_hull[uh - 1].id);
      grafo[upper_hull[uh - 1].id].push_back(upper_hull[uh].id);
    }
  }
  DFS(n, 0);
  for (int k = 1; k < 20; k++)
    for (int g = 1; g <= n; g++) dp[g][k] = dp[dp[g][k - 1]][k - 1];
  scanf("%d", &q);
  for (int g = 0; g < q; g++) {
    scanf("%d %d", &n1, &n2);
    printf("%d\n", LCA(n1, n2));
  }
}
