#include <bits/stdc++.h>
using namespace std;
int x[100000];
long long y[100001];
int h[100000];
int f[100000][20];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d%I64d", x + i, y + i);
  f[n - 1][0] = n - 1;
  vector<int> q(1, n - 1);
  for (int i = n - 2; i >= 0; --i) {
    for (; q.size() >= 2; q.pop_back()) {
      int j = q.back(), k = *(q.end() - 2);
      if ((x[j] - x[i]) * (y[k] - y[i]) - (x[k] - x[i]) * (y[j] - y[i]) <= 0)
        break;
    }
    f[i][0] = q.back();
    q.push_back(i);
  }
  for (int i = n - 2; i >= 0; --i) h[i] = h[f[i][0]] + 1;
  for (int i = 1; i < 20; ++i)
    for (int j = 0; j < n; ++j) f[j][i] = f[f[j][i - 1]][i - 1];
  {
    int q;
    scanf("%d", &q);
    for (int a, b; q--;) {
      scanf("%d%d", &a, &b);
      --a;
      --b;
      if (h[a] < h[b]) swap(a, b);
      for (int t = h[a] - h[b], k; t; t ^= t & -t) a = f[a][__builtin_ctz(t)];
      for (int k = 19; a != b;) {
        for (; k && f[a][k] == f[b][k]; --k)
          ;
        a = f[a][k];
        b = f[b][k];
      }
      printf("%d ", a + 1);
    }
  }
}
