#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e5;
vector<int> lst[N + 1], tin, tout, up[N + 1];
int n, m, x[N + 1], l = 1, timer = 0;
long long y[N + 1];
void dfs(int v, int p) {
  tin[v] = ++timer;
  up[v][0] = p;
  for (int i = 1; i <= l; ++i) up[v][i] = up[up[v][i - 1]][i - 1];
  for (int i = 0; i < lst[v].size(); ++i) dfs(lst[v][i], v);
  tout[v] = ++timer;
}
bool upper(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
int lca(int a, int b) {
  if (upper(a, b)) return a;
  if (upper(b, a)) return b;
  for (int i = l; i >= 0; --i)
    if (!upper(up[a][i], b)) a = up[a][i];
  return up[a][0];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) cin >> x[i] >> y[i];
  deque<int> deq(1, n);
  for (int i = n - 1; i; --i) {
    while (deq.size() > 1 && (x[deq[0]] - x[i]) * (y[deq[1]] - y[i]) >
                                 (y[deq[0]] - y[i]) * (x[deq[1]] - x[i]))
      deq.pop_front();
    lst[deq[0]].push_back(i);
    deq.push_front(i);
  }
  while ((1 << l) <= n) ++l;
  for (int i = 1; i <= n; ++i) up[i].resize(l + 1);
  tin.resize(n + 1);
  tout.resize(n + 1);
  dfs(n, n);
  scanf("%d", &m);
  for (int a, b; m; --m) {
    scanf("%d%d", &a, &b);
    printf("%d ", lca(a, b));
  }
  puts("");
  return 0;
}
