#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
pair<long long, long long> pnt[100005];
pair<long long, long long> convex[100005];
int cid[100005];
vector<int> e[100005];
int dp[100005][25];
int dep[100005];
void dfs(int now, int d) {
  dep[now] = d;
  for (int val : e[now]) dfs(val, d + 1);
}
long long cross(pair<long long, long long> a, pair<long long, long long> b,
                pair<long long, long long> c) {
  pair<long long, long long> va =
      make_pair(b.first - a.first, b.second - a.second);
  pair<long long, long long> vb =
      make_pair(c.first - b.first, c.second - b.second);
  return va.first * vb.second - va.second * vb.first;
}
int LCA(int a, int b) {
  if (dep[a] < dep[b]) swap(a, b);
  int d = dep[a] - dep[b];
  for (int k = 20; k >= 0; --k)
    if (d & (1 << k)) a = dp[a][k];
  if (a == b) return a;
  for (int k = 20; k >= 0; --k)
    if (dp[a][k] != dp[b][k]) a = dp[a][k], b = dp[b][k];
  return dp[a][0];
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf(
        "%lld"
        "%lld",
        &pnt[i].first, &pnt[i].second);
  int m = 1;
  convex[0] = pnt[n - 1];
  cid[0] = n - 1;
  dp[n - 1][0] = n - 1;
  for (int i = n - 2; i >= 0; --i) {
    while (m >= 2 and cross(pnt[i], convex[m - 1], convex[m - 2]) > 0) --m;
    int fa = cid[m - 1];
    e[fa].push_back(i);
    dp[i][0] = fa;
    cid[m] = i;
    convex[m++] = pnt[i];
  }
  dfs(n - 1, 0);
  for (int j = 1; j <= 20; ++j)
    for (int i = 0; i < n; ++i) dp[i][j] = dp[dp[i][j - 1]][j - 1];
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d %d", &a, &b);
    --a, --b;
    printf("%d ", LCA(a, b) + 1);
  }
  printf("\n");
}
