#include <bits/stdc++.h>
using namespace std;
const long long inf = 2e18;
const long long mod = 1e9 + 7;
const double Pi = acos(-1);
long long n;
long long x[100009], y[100009], dp[100009][21], lev[100009];
long long check(long long i, long long j, long long k) {
  return (x[j] - x[i]) * (y[k] - y[i]) <= (x[k] - x[i]) * (y[j] - y[i]);
}
long long lca(long long a, long long b) {
  if (lev[a] < lev[b]) swap(a, b);
  long long l = lev[a] - lev[b];
  for (int i = 0; i < 20; i++) {
    if ((l & (1ll << i))) {
      a = dp[a][i];
    }
  }
  if (a == b) return a;
  for (int i = 19; i >= 0; i--) {
    if (dp[a][i] != dp[b][i]) {
      a = dp[a][i];
      b = dp[b][i];
    }
  }
  return dp[a][0];
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  vector<int> points;
  dp[n - 1][0] = n - 1;
  points.push_back(n - 1);
  for (int i = n - 2; i >= 0; i--) {
    while (points.size() >= 2) {
      int j = points.back();
      int k = points[points.size() - 2];
      if (check(i, j, k)) break;
      points.pop_back();
    }
    dp[i][0] = points.back();
    points.push_back(i);
  }
  for (int i = n - 1; i >= 0; i--) {
    lev[i] = lev[dp[i][0]] + 1;
  }
  for (int j = 1; j < 20; j++) {
    for (int i = 0; i < n; i++) {
      dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << lca(x, y) + 1 << " ";
  }
  cout << endl;
}
