#include <bits/stdc++.h>
using namespace std;
const long long MX = (1 << 17), MXL = 17;
long long n, nxt[MXL][MX];
bool cw(pair<long long, long long> a, pair<long long, long long> b,
        pair<long long, long long> c) {
  return 1ll * (b.first - a.first) * (c.second - b.second) <
         1ll * (b.second - a.second) * (c.first - b.first);
}
int depth[MX];
pair<long long, long long> arr[MX];
int main() {
  scanf("%lld", &n);
  for (long long j = 1; j <= n; j++)
    scanf("%lld %lld", &arr[j].first, &arr[j].second);
  long long who = 0;
  nxt[0][n] = n + 1;
  depth[n] = 1;
  vector<int> v;
  v.push_back(n);
  int sz = 1;
  for (long long j = n - 1; j; j--) {
    while (sz >= 2 && cw(arr[v[sz - 2]], arr[v[sz - 1]], arr[j])) {
      v.pop_back();
      --sz;
    }
    depth[j] = depth[v.back()] + 1;
    nxt[0][j] = v.back();
    v.push_back(j);
    ++sz;
  }
  for (long long j = 1; j < MXL; j++)
    for (long long i = n; i; i--) nxt[j][i] = nxt[j - 1][nxt[j - 1][i]];
  long long QN;
  scanf("%lld", &QN);
  while (QN--) {
    long long src, snk;
    scanf("%lld %lld", &src, &snk);
    if (depth[src] < depth[snk]) swap(src, snk);
    int d = depth[src] - depth[snk];
    for (int j = MXL - 1; j >= 0; j--)
      if ((d & (1 << j))) {
        src = nxt[j][src];
      }
    if (src == snk) goto pp;
    for (int j = MXL - 1; j >= 0; j--)
      if (nxt[j][src] != nxt[j][snk]) src = nxt[j][src], snk = nxt[j][snk];
    src = nxt[0][src];
  pp:;
    printf("%lld\n", src);
  }
}
