#include <bits/stdc++.h>
using namespace std;
template <typename T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const int maxn = 100005;
pair<long long, long long> a[maxn];
int p[maxn][20];
vector<int> g[maxn];
int height[maxn];
void dfs(int v) {
  for (int to : g[v]) {
    height[to] = height[v] + 1;
    dfs(to);
  }
}
int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  vector<int> st;
  for (int i = 0; i < n; i++) {
    p[i][0] = i;
    cin >> a[i].first >> a[i].second;
  }
  st.push_back(n - 1);
  for (int i = n - 2; i >= 0; i--) {
    if (st.size() == 1) {
      p[i][0] = st[0];
      st.push_back(i);
    } else {
      while (st.size() > 1) {
        int u = st[st.size() - 2], v = st[st.size() - 1];
        if ((a[u].second - a[i].second) * (a[v].first - a[i].first) >
            (a[v].second - a[i].second) * (a[u].first - a[i].first)) {
          st.pop_back();
        } else
          break;
      }
      p[i][0] = st.back();
      st.push_back(i);
    }
  }
  for (int i = 0; i < n; i++) {
    if (p[i][0] != i) g[p[i][0]].push_back(i);
  }
  for (int i = n - 1; i >= 0; i--)
    for (int j = 1; j < 20; j++) p[i][j] = p[p[i][j - 1]][j - 1];
  dfs(n - 1);
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    if (height[u] < height[v]) swap(u, v);
    int diff = height[u] - height[v];
    for (int j = 0; j < 20; j++)
      if (diff & (1 << j)) u = p[u][j];
    if (i) cout << " ";
    if (u == v) {
      cout << u + 1;
      continue;
    }
    int ans;
    for (int j = 19; j >= 0; j--) {
      if (p[u][j] == p[v][j])
        ans = p[u][j];
      else {
        u = p[u][j];
        v = p[v][j];
      }
    }
    cout << ans + 1;
  }
  return 0;
}
