#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
long long x[maxn], y[maxn];
int anc[maxn][32], L[maxn], fa[maxn];
vector<int> adj[maxn];
int n, m;
int LCA(int p, int q) {
  int log;
  if (L[p] < L[q]) swap(p, q);
  for (log = 1; (1 << log) <= L[p]; log++)
    ;
  log--;
  for (int i = log; i >= 0; i--)
    if (L[p] - (1 << i) >= L[q]) {
      p = anc[p][i];
    }
  if (p == q) return p;
  for (int i = log; i >= 0; i--)
    if (anc[p][i] != -1 && anc[p][i] != anc[q][i]) {
      p = anc[p][i];
      q = anc[q][i];
    }
  return fa[p];
}
void dfs(int u, int f, int d) {
  L[u] = d;
  fa[u] = anc[u][0] = f;
  for (int j = 1; (1 << j) < n; j++) anc[u][j] = -1;
  for (int j = 1; (1 << j) < n; j++)
    if (anc[u][j - 1] != -1) {
      int a = anc[u][j - 1];
      anc[u][j] = anc[a][j - 1];
    }
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == f) continue;
    dfs(v, u, d + 1);
  }
}
bool check(int i, int j, int k) {
  double a = ((x[j] - x[i]) * (y[k] - y[i]) - (x[k] - x[i]) * (y[j] - y[i]));
  if (a <= 0) return false;
  return true;
}
int main(int argc, char *argv[]) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%I64d%I64d", x + i, y + i);
  }
  vector<int> qs;
  qs.push_back(n - 1);
  for (int i = n - 2; i >= 0; i--) {
    while (qs.size() > 1 && check(i, qs.back(), qs[qs.size() - 2]))
      qs.pop_back();
    adj[qs.back()].push_back(i);
    qs.push_back(i);
  }
  dfs(n - 1, -1, 1);
  scanf("%d", &m);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    int f = LCA(u, v) + 1;
    printf("%d ", f);
  }
  printf("\n");
  return 0;
}
