#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
struct edge {
  int v, next;
} e[N * 2];
int cnt, head[N];
void addedge(int u, int v) {
  e[cnt].v = v;
  e[cnt].next = head[u];
  head[u] = cnt++;
}
int P[N][25], pat[N], L[N], dis[N];
void dfs(int fa, int u, int dist, int dep) {
  dis[u] = dist;
  L[u] = dep;
  pat[u] = fa;
  for (int i = head[u]; i != -1; i = e[i].next)
    if (e[i].v != fa) dfs(u, e[i].v, dist + 1, dep + 1);
}
void init_lca(int n) {
  int i, j;
  for (i = 1; i <= n; i++) P[i][0] = pat[i];
  for (j = 1; (1 << j) <= n; j++)
    for (i = 1; i <= n; i++)
      if (P[i][j - 1] != -1) P[i][j] = P[P[i][j - 1]][j - 1];
}
int query_lca(int p, int q) {
  if (L[p] < L[q]) swap(p, q);
  int i, log;
  for (log = 1; (1 << log) <= L[p]; log++)
    ;
  log--;
  for (i = log; i >= 0; i--)
    if (L[p] - (1 << i) >= L[q]) p = P[p][i];
  if (p == q) return p;
  for (i = log; i >= 0; i--)
    if (P[p][i] != -1 && P[p][i] != P[q][i]) p = P[p][i], q = P[q][i];
  return pat[p];
}
stack<int> stk;
long long a[N], b[N];
int main() {
  memset(P, -1, sizeof(P));
  memset(head, -1, sizeof(head));
  int n, m;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d%I64d", &a[i], &b[i]);
  for (int i = n; i >= 1; i--) {
    if (stk.empty())
      stk.push(i);
    else {
      while (stk.size() >= 2) {
        int x = stk.top();
        stk.pop();
        int y = stk.top();
        stk.pop();
        if ((a[i] - a[x]) * (b[y] - b[x]) - (b[i] - b[x]) * (a[y] - a[x]) < 0) {
          stk.push(y);
          continue;
        }
        stk.push(y);
        stk.push(x);
        break;
      }
      addedge(stk.top(), i);
      stk.push(i);
    }
  }
  dfs(n, n, 0, 0);
  init_lca(n);
  scanf("%d", &m);
  int x, y;
  while (m--) {
    scanf("%d%d", &x, &y);
    printf("%d ", query_lca(x, y));
  }
  cout << endl;
  return 0;
}
