#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long int N = 1e5 + 5;
const long long int LOGN = 18;
vector<long long int> st;
long long int x[N], y[N];
long long int dp[LOGN][N], depth[N];
long long int cross(long long int i, long long int j, long long int k) {
  return (x[j] - x[i]) * (y[k] - y[j]) - (x[k] - x[j]) * (y[j] - y[i]);
}
long long int lca(long long int u, long long int v) {
  if (depth[u] < depth[v]) swap(u, v);
  for (long long int k = LOGN - 1; k >= 0; k--) {
    if (depth[dp[k][u]] >= depth[v]) u = dp[k][u];
  }
  if (u == v) return u;
  for (long long int k = LOGN - 1; k >= 0; k--) {
    if (dp[k][u] != dp[k][v]) u = dp[k][u], v = dp[k][v];
  }
  return dp[0][u];
}
void solve() {
  long long int n;
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
  }
  depth[n] = 1;
  for (long long int i = n; i >= 1; i--) {
    while (st.size() >= 2 && cross(i, st[st.size() - 1], st[st.size() - 2]) > 0)
      st.pop_back();
    if (!st.empty()) {
      dp[0][i] = st.back();
      depth[i] = depth[st.back()] + 1;
    }
    st.push_back(i);
  }
  for (long long int k = 1; k <= LOGN - 1; k++) {
    for (long long int i = 1; i <= n; i++) {
      dp[k][i] = dp[k - 1][dp[k - 1][i]];
    }
  }
  long long int m;
  cin >> m;
  for (long long int i = 1; i <= m; i++) {
    long long int u, v;
    cin >> u >> v;
    cout << lca(u, v) << " ";
  }
}
signed main() {
  ios ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  clock_t clk = clock();
  long long int t;
  t = 1;
  while (t--) {
    solve();
  }
  cerr << '\n' << (double)(clock() - clk) / CLOCKS_PER_SEC;
  return 0;
}
