#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
  point(long long x = 0, long long y = 0) : x(x), y(y) {}
};
point operator-(point a, point b) { return point(a.x - b.x, a.y - b.y); }
bool turn(point a, point b, point c) {
  point p1 = point(b - a);
  point p2 = point(c - b);
  return (p1.x * p2.y - p1.y * p2.x) > 0;
}
int n, de, m, a, b;
vector<point> d;
vector<int> st;
vector<vector<int> > g;
vector<int> h;
vector<vector<int> > anc;
void dfs(int v, int p = -1) {
  h[v] = de++;
  if (p == -1)
    anc[v][0] = v;
  else
    anc[v][0] = p;
  for (int i = 0; i < g[v].size(); i++) {
    if (g[v][i] == p) continue;
    dfs(g[v][i], v);
  }
  de--;
}
int lca(int a, int b) {
  if (h[a] < h[b]) swap(a, b);
  for (int i = 17; i >= 0; i--) {
    if (h[anc[a][i]] >= h[b]) a = anc[a][i];
  }
  if (a == b) return a;
  for (int i = 17; i >= 0; i--) {
    if (anc[a][i] != anc[b][i]) {
      a = anc[a][i];
      b = anc[b][i];
    }
  }
  if (a == b)
    return b;
  else
    return anc[a][0];
}
int main() {
  cin >> n;
  d.resize(n);
  g.resize(n);
  h.resize(n);
  anc.resize(n);
  for (int i = 0; i < n; i++) {
    anc[i].resize(18);
    cin >> d[i].x >> d[i].y;
  }
  st.push_back(n - 1);
  for (int i = n - 2; i >= 0; i--) {
    while ((st.size() > 1) &&
           turn(d[i], d[st[st.size() - 1]], d[st[st.size() - 2]])) {
      st.pop_back();
    }
    g[i].push_back(st[st.size() - 1]);
    g[st[st.size() - 1]].push_back(i);
    st.push_back(i);
  }
  de = 0;
  dfs(n - 1);
  for (int j = 1; j < 18; j++) {
    for (int i = 0; i < n; i++) {
      anc[i][j] = anc[anc[i][j - 1]][j - 1];
    }
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--;
    b--;
    cout << lca(a, b) + 1 << " ";
  }
  cout << endl;
}
