#include <bits/stdc++.h>
using namespace std;
int fa[100005][20], dep[100005];
vector<int> st;
pair<long long, long long> p[100005];
long long cross(pair<long long, long long> o, pair<long long, long long> a,
                pair<long long, long long> b) {
  long long ax = a.first - o.first, ay = a.second - o.second;
  long long bx = b.first - o.first, by = b.second - o.second;
  return ax * by - ay * bx;
}
int jump(int u, int d) {
  for (int j = 19; j >= 0; --j)
    if ((1 << j) <= d) u = fa[u][j], d -= 1 << j;
  return u;
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  int d = dep[u] - dep[v];
  u = jump(u, d);
  for (int j = 19; j >= 0; --j)
    if (fa[u][j] != fa[v][j]) u = fa[u][j], v = fa[v][j];
  return u == v ? u : fa[u][0];
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, q, a, b;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> p[i].first >> p[i].second;
  dep[n] = 0;
  fa[n][0] = n;
  for (int i = n; i >= 1; --i) {
    while (st.size() > 1 && cross(p[i], p[st.back()], p[st[st.size() - 2]]) > 0)
      st.pop_back();
    if (st.size()) {
      fa[i][0] = st.back();
      dep[i] = dep[fa[i][0]] + 1;
    }
    st.push_back(i);
  }
  for (int j = 0; j < 19; ++j)
    for (int i = 1; i <= n; ++i) fa[i][j + 1] = fa[fa[i][j]][j];
  cin >> q;
  while (q--) {
    cin >> a >> b;
    cout << lca(a, b) << " ";
  }
  return 0;
}
