#include <bits/stdc++.h>
using namespace std;
const int MAXN = 210000;
double x[MAXN], y[MAXN];
int n;
int root;
int fa[22][MAXN];
vector<int> p[MAXN];
int dep[MAXN];
int q[MAXN];
int top;
void dfs(int a) {
  dep[a] = dep[fa[0][a]] + 1;
  for (int i = (0); i <= (int)p[a].size() - 1; i++) dfs(p[a][i]);
}
int lca(int a, int b) {
  if (dep[a] < dep[b]) swap(a, b);
  for (int i = (20); i >= (int)0; i--)
    if ((1 << i) & (dep[a] - dep[b])) a = fa[i][a];
  if (a == b) return a;
  for (int i = (20); i >= (int)0; i--)
    if (fa[i][a] != fa[i][b]) {
      a = fa[i][a];
      b = fa[i][b];
    }
  return fa[0][a];
}
double cha(double x0, double y0, double x1, double y1, double x2, double y2) {
  x1 -= x0;
  y1 -= y0;
  x2 -= x0;
  y2 -= y0;
  return x1 * y2 - x2 * y1;
}
int main() {
  scanf("%d", &n);
  root = n;
  for (int i = (1); i <= (int)n; i++) {
    long long x1, y1;
    scanf("%I64d%I64d", &x1, &y1);
    x[i] = 1. * x1;
    y[i] = 1. * y1;
  }
  q[top = 1] = n;
  for (int i = (n - 1); i >= (int)1; i--) {
    while (top > 1 && cha(x[i], y[i], x[q[top]], y[q[top]], x[q[top - 1]],
                          y[q[top - 1]]) > 0)
      top--;
    fa[0][i] = q[top];
    p[q[top]].push_back(i);
    q[++top] = i;
  }
  dfs(root);
  for (int j = (1); j <= (int)20; j++)
    for (int i = (1); i <= (int)n; i++) fa[j][i] = fa[j - 1][fa[j - 1][i]];
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d ", lca(a, b));
  }
  return 0;
}
