#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
const int M = 5007;
const int inf = 1e9 + 7;
const long long base = 1e18;
const double pi = acos(-1);
const double ep = 1e-9;
int st[N], k;
int rightMost[N];
int x[N];
long long y[N];
vector<int> adj[N];
int pa[N][20];
int d[N];
int n;
void DFS(int u) {
  for (int j = 0; j < adj[u].size(); j++) {
    int v = adj[u][j];
    if (pa[v][0] == 0) {
      pa[v][0] = u;
      d[v] = d[u] + 1;
      for (int i = 1; i < 20; i++) pa[v][i] = pa[pa[v][i - 1]][i - 1];
      DFS(v);
    }
  }
}
int LCA(int u, int v) {
  if (d[u] < d[v]) swap(u, v);
  for (int i = 20; i > -1; i--) {
    if (d[u] - (1 << i) >= d[v]) u = pa[u][i];
  }
  if (u == v) return u;
  for (int i = 20; i > -1; i--) {
    if ((d[u] - (1 << i) >= 0) && pa[u][i] != pa[v][i]) {
      u = pa[u][i];
      v = pa[v][i];
    }
  }
  return pa[u][0];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n + 1; i++) {
    scanf("%d%I64d", x + i, y + i);
  }
  rightMost[n] = n;
  st[++k] = n;
  for (int i = n - 1; i > 0; i--) {
    int last = st[1];
    while (k > 0 && y[st[k]] <= y[i]) k--;
    while (k > 1 && (y[st[k]] - y[i]) * (x[st[k - 1]] - x[i]) <
                        (y[st[k - 1]] - y[i]) * (x[st[k]] - x[i]))
      k--;
    if (k > 0)
      rightMost[i] = st[k];
    else {
      while (last != n) {
        int tmp = rightMost[last];
        if ((x[tmp] - x[i]) * (y[i] - y[last]) >
            (x[last] - x[i]) * (y[i] - y[tmp]))
          last = tmp;
        else
          break;
      }
      rightMost[i] = last;
    }
    adj[rightMost[i]].push_back(i);
    st[++k] = i;
  }
  for (int i = 0; i < 20; i++) pa[n][i] = -1;
  DFS(n);
  int test;
  cin >> test;
  while (test--) {
    int u, v;
    scanf("%d%d", &u, &v);
    printf("%d ", LCA(u, v));
  }
  return 0;
}
