#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:20000000")
using namespace std;
int ri() {
  int x;
  scanf("%d", &x);
  return x;
}
long long rll() {
  long long x;
  scanf("%I64d", &x);
  return x;
}
int rind[100500];
vector<pair<long long, long long> > mas;
bool check(int a, int b, int c) {
  return mas[a].first * (mas[b].second - mas[c].second) +
             mas[b].first * (mas[c].second - mas[a].second) +
             mas[c].first * (mas[a].second - mas[b].second) >
         0;
}
vector<vector<int> > graph;
vector<vector<int> > up;
int tin[100500];
int tout[100500];
int L = 1;
int timer = 0;
void go(int v, int p) {
  tin[v] = ++timer;
  up[v][0] = p;
  for (int i = 1; i <= L; i++) up[v][i] = up[up[v][i - 1]][i - 1];
  for (int i = 0; i < graph[v].size(); i++)
    if (graph[v][i] != p) go(graph[v][i], v);
  tout[v] = ++timer;
}
bool upper(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
int lca(int a, int b) {
  if (upper(a, b)) return a;
  if (upper(b, a)) return b;
  for (int i = L; i >= 0; i--)
    if (!upper(up[a][i], b)) a = up[a][i];
  return up[a][0];
}
void solve() {
  int n = ri();
  mas.resize(n);
  for (int i = 0; i < n; i++) mas[i].first = rll(), mas[i].second = rll();
  rind[n - 1] = n - 1;
  graph.resize(n);
  for (int i = n - 2; i >= 0; i--) {
    int pos = i + 1;
    while (pos != n - 1 && check(i, pos, rind[pos])) pos = rind[pos];
    rind[i] = pos;
    graph[pos].push_back(i);
    graph[i].push_back(pos);
  }
  while ((1 << L) <= n) L++;
  up.resize(n);
  for (int i = 0; i < n; i++) up[i].resize(L + 1);
  go(n - 1, n - 1);
  int m = ri();
  for (int i = 0; i < m; i++) {
    int a = ri() - 1, b = ri() - 1;
    if (a > b) swap(a, b);
    printf("%d ", lca(a, b) + 1);
  }
}
int main() {
  solve();
  return 0;
}
