#include <bits/stdc++.h>
using namespace std;
struct frac {
  int64_t a = -1e11;
  int64_t b = 0;
  frac() {}
  frac(int64_t ia, int64_t ib) : a(ia), b(ib) {}
  bool operator<(const frac& ot) const { return a * ot.b < b * ot.a; }
};
struct table {
  int64_t n;
  vector<int64_t> xs;
  vector<int64_t> ys;
  vector<int64_t> par;
  bool bad(int64_t s, int64_t fs, int64_t sn) {
    return frac(ys[fs] - ys[s], xs[fs] - xs[s]) <
           frac(ys[sn] - ys[s], xs[sn] - xs[s]);
  }
  void calc() {
    vector<int64_t> st;
    par[n - 1] = n - 1;
    st.push_back(n - 1);
    for (int64_t i = n - 2; i >= 0; i--) {
      while (st.size() > 1 && bad(i, st.back(), st[st.size() - 2]))
        st.pop_back();
      par[i] = st.back();
      st.push_back(i);
    }
  }
};
struct lca {
  int64_t n;
  int64_t lgn;
  vector<vector<int64_t>> par;
  vector<int64_t> lvl;
  lca(int64_t in, vector<int64_t> init)
      : n(in),
        lgn((8 * sizeof(long long) - __builtin_clzll(n)) + 1),
        par(vector<vector<int64_t>>(lgn, vector<int64_t>(n, -1))),
        lvl(vector<int64_t>(n)) {
    par[0] = init;
    for (int64_t i = 1; i < lgn; i++) {
      for (int64_t j = 0; j < n; j++) par[i][j] = par[i - 1][par[i - 1][j]];
    }
    lvl[0] = 0;
    for (int64_t i = n - 2; i >= 0; i--) {
      lvl[i] = lvl[par[0][i]] + 1;
    }
  }
  int64_t query(int64_t a, int64_t b) {
    if (lvl[a] < lvl[b]) swap(a, b);
    int64_t ld = lvl[a] - lvl[b];
    for (int64_t i = 0; i < lgn; i++)
      if (ld & (1ll << i)) a = par[i][a];
    if (a == b) return a;
    for (int64_t i = lgn - 1; i >= 0; i--) {
      if (par[i][a] != par[i][b]) {
        a = par[i][a];
        b = par[i][b];
      }
    }
    return par[0][a];
  }
};
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int64_t n;
  cin >> n;
  table t;
  t.n = n;
  t.xs.resize(n);
  t.ys.resize(n);
  t.par.resize(n, n - 1);
  for (int64_t i = 0; i < n; i++) cin >> t.xs[i] >> t.ys[i];
  t.calc();
  lca l(n, t.par);
  int64_t q;
  cin >> q;
  for (int64_t i = 0; i < q; i++) {
    int64_t a, b;
    cin >> a >> b;
    a--;
    b--;
    cout << l.query(a, b) + 1 << " ";
  }
  cout << "\n";
}
