#include <bits/stdc++.h>
using namespace std;
template <class P, class Q>
inline void smin(P &a, Q b) {
  if (b < a) a = b;
}
template <class P, class Q>
inline void smax(P &a, Q b) {
  if (a < b) a = b;
}
const int maxn = 100000 + 100;
int n;
long long x[maxn], y[maxn];
int d[maxn], r[maxn];
int par[20][maxn];
int lca(int u, int v) {
  if (d[u] > d[v]) swap(u, v);
  for (int i = (int)(20), _x = (int)(0); i-- > _x;)
    if (d[v] - (1 << i) >= d[u]) v = par[i][v];
  if (u == v) return u;
  for (int i = (int)(20), _x = (int)(0); i-- > _x;)
    if (par[i][u] != par[i][v]) u = par[i][u], v = par[i][v];
  return par[0][u];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0, _n = (int)(n); i < _n; i++) cin >> x[i] >> y[i];
  for (int i = (int)(n - 1), _x = (int)(0); i-- > _x;) {
    if (i < n - 1) {
      r[i] = i + 1;
      while (r[i] != n - 1 && (y[r[r[i]]] - y[i]) * (x[r[i]] - x[i]) >
                                  (y[r[i]] - y[i]) * (x[r[r[i]]] - x[i]))
        r[i] = r[r[i]];
      d[i] = d[r[i]] + 1;
    } else
      r[i] = i, d[i] = 0;
    par[0][i] = r[i];
    for (int j = (int)(1), _n = (int)(20); j < _n; j++)
      par[j][i] = par[j - 1][par[j - 1][i]];
  }
  int q;
  cin >> q;
  for (int i = 0, _n = (int)(q); i < _n; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    cout << lca(u, v) + 1 << ' ';
  }
  cout << endl;
  { return 0; }
}
