#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
long long first[MAX], second[MAX], par[20][MAX], d[MAX], n;
vector<int> adj[MAX];
int ccw(pair<long long, long long> a, pair<long long, long long> b,
        pair<long long, long long> c) {
  long long ans = (b.first - a.first) * (c.second - a.second) -
                  (b.second - a.second) * (c.first - a.first);
  if (ans < 0) ans = -1;
  if (ans > 0) ans = 1;
  return ans;
}
struct line {
  pair<long long, long long> a, b;
  line(pair<long long, long long> _a, pair<long long, long long> _b) {
    a = _a;
    b = _b;
  }
};
bool intersect(line l1, line l2) {
  int t1 = ccw(l1.a, l1.b, l2.a) * ccw(l1.a, l1.b, l2.b);
  int t2 = ccw(l2.a, l2.b, l1.a) * ccw(l2.a, l2.b, l1.b);
  return (t1 <= 0 && t2 <= 0);
}
bool seen(int i, int j, int k) {
  line l1(pair<long long, long long>(first[i], second[i]),
          pair<long long, long long>(first[k], second[k]));
  line l2(pair<long long, long long>(first[j], 0),
          pair<long long, long long>(first[j], second[j]));
  return (!intersect(l1, l2));
}
void dfs(int p, int v) {
  d[v] = d[p] + 1;
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i];
    if (u != p) dfs(v, u);
  }
}
void init() {
  for (int h = 1; h < 20; h++)
    for (int v = 1; v <= n; v++) par[h][v] = par[h - 1][par[h - 1][v]];
}
int get_parent(int v, int k) {
  for (int h = 0; h < 20; h++)
    if ((1 << h) & k) v = par[h][v];
  return v;
}
int lca(int u, int v) {
  if (d[u] < d[v]) swap(u, v);
  u = get_parent(u, d[u] - d[v]);
  if (u == v) return v;
  for (int h = 19; h >= 0; h--)
    if (par[h][u] != par[h][v]) {
      u = par[h][u];
      v = par[h][v];
    }
  return par[0][v];
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> first[i] >> second[i];
  vector<int> v;
  v.push_back(n);
  for (int i = n - 1; i >= 1; i--) {
    par[0][i] = v.back();
    while (v.size() > 1) {
      if (seen(i, par[0][i], v[v.size() - 2])) {
        par[0][i] = v[v.size() - 2];
        v.pop_back();
      } else
        break;
    }
    v.push_back(i);
  }
  for (int v = 1; v <= n; v++)
    if (par[0][v] != 0) {
      adj[v].push_back(par[0][v]);
      adj[par[0][v]].push_back(v);
    }
  dfs(0, n);
  init();
  int q;
  cin >> q;
  while (q--) {
    int u, v;
    cin >> u >> v;
    cout << lca(u, v) << " ";
  }
  cout << endl;
  return 0;
}
