#include <bits/stdc++.h>
using namespace std;
inline long long next_int() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long next_long() {
  long long x;
  scanf("%lld", &x);
  return x;
}
const long long maxn = 2e5 + 10;
long long x[maxn], y[maxn];
const long long maxlg = 22;
inline long long ccw(long long a, long long b, long long c) {
  return (x[b] - x[a]) * (y[c] - y[a]) - (y[b] - y[a]) * (x[c] - x[a]);
}
long long h[maxn], root[maxn][maxlg];
vector<long long> g[maxn];
inline void dfs(long long node, long long fa = -1, long long h = 0) {
  ::h[node] = h;
  if (fa + 1) root[node][0] = fa;
  for (long long i = 1; i < maxlg; i++) {
    if ((1 << i) <= ::h[node]) root[node][i] = root[root[node][i - 1]][i - 1];
  }
  for (auto u : g[node])
    if (u - fa) dfs(u, node, h + 1);
}
inline long long lca(long long v, long long u) {
  if (h[v] < h[u]) swap(v, u);
  for (long long i = maxlg - 1; i >= 0; i--)
    if (h[v] - (1 << i) >= h[u]) v = root[v][i];
  if (v == u) return v;
  for (long long i = maxlg - 1; i >= 0; i--)
    if (root[v][i] != root[u][i]) v = root[v][i], u = root[u][i];
  return root[v][0];
}
long long STACK[maxn], t;
int32_t main() {
  long long n = next_int();
  for (long long i = 0; i < n; i++) x[i] = next_int(), y[i] = next_long();
  long long m = next_int();
  STACK[t++] = n - 1;
  for (long long i = n - 2; i >= 0; i--) {
    while (t >= 2 && ccw(i, STACK[t - 1], STACK[t - 2]) > 0) {
      t--;
    }
    g[STACK[t - 1]].push_back(i);
    STACK[t++] = i;
  }
  dfs(n - 1);
  for (long long i = 0; i < m; i++) {
    long long v = next_int() - 1, u = next_int() - 1;
    printf("%lld ", lca(v, u) + 1);
  }
}
