#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long int, long long int> m1,
         pair<long long int, long long int> m2) {
  return m1.first * m2.second < m2.first * m1.second;
}
int P[100010][20];
int lvl[100010];
pair<long long int, long long int> v[100010], elev[100010];
;
int nxt[100010];
int lca(int p, int q) {
  if (lvl[p] < lvl[q]) swap(p, q);
  for (int i = 19; i >= 0; i--)
    if (P[p][i] != -1 && lvl[P[p][i]] >= lvl[q]) p = P[p][i];
  if (p == q) return p;
  for (int i = 19; i >= 0; i--)
    if (P[p][i] != P[q][i]) {
      p = P[p][i];
      q = P[q][i];
    }
  return P[p][0];
}
int main() {
  cin.tie(NULL);
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> v[i].first >> v[i].second;
  nxt[N - 1] = -1;
  lvl[N - 1] = 0;
  elev[N - 1] = make_pair(-1, 0);
  for (int i = N - 2; i >= 0; i--) {
    nxt[i] = i + 1;
    lvl[i] = lvl[nxt[i]] + 1;
    long long int n = v[nxt[i]].second - v[i].second,
                  d = v[nxt[i]].first - v[i].first;
    while (cmp(make_pair(n, d), elev[nxt[i]])) {
      nxt[i] = nxt[nxt[i]];
      lvl[i] = lvl[nxt[i]] + 1;
      n = v[nxt[i]].second - v[i].second, d = v[nxt[i]].first - v[i].first;
    }
    elev[i] = make_pair(n, d);
  }
  for (int i = 0; i < N; i++) P[i][0] = nxt[i];
  for (int i = 1; i < 20; i++)
    for (int j = 0; j < N; j++)
      P[j][i] = (P[j][i - 1] != -1 ? P[P[j][i - 1]][i - 1] : -1);
  int M;
  cin >> M;
  for (int i = 0; i < M; i++) {
    int p, q;
    cin >> p >> q;
    p--;
    q--;
    cout << lca(p, q) + 1 << " ";
  }
  cout << endl;
  return 0;
}
