#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int f[maxn][20], dp[maxn];
struct point {
  long long x, y;
  point(long long x = 0, long long y = 0) : x(x), y(y) {}
  void input() { scanf("%lld%lld", &x, &y); }
  point operator-(const point& A) const { return point(x - A.x, y - A.y); }
} pt[maxn];
void add_edge(int a, int b) {
  f[a + 1][0] = b + 1;
  dp[a + 1] = dp[b + 1] + 1;
}
int n;
long long vect(point A, point B) { return A.x * B.y - A.y * B.x; }
long long vect(point A, point B, point C) { return vect(B - A, C - A); }
void init() {
  for (int i = 1; i < 20; i++)
    for (int j = 1; j <= n; j++) f[j][i] = f[f[j][i - 1]][i - 1];
}
pair<point, int> cv[maxn];
int LCA(int u, int v) {
  if (dp[u] < dp[v]) swap(u, v);
  int i;
  for (i = 20 - 1; i >= 0; i--) {
    if (dp[f[u][i]] >= dp[v]) u = f[u][i];
    if (u == v) return u;
  }
  for (i = 20 - 1; i >= 0; i--)
    if (f[u][i] != f[v][i]) u = f[u][i], v = f[v][i];
  return f[u][0];
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) pt[i].input();
  int ind = 0;
  cv[ind++] = make_pair(pt[n - 1], n - 1);
  dp[n] = 1;
  if (n > 1) {
    cv[ind++] = make_pair(pt[n - 2], n - 2);
    add_edge(n - 2, n - 1);
  }
  for (int i = n - 3; i >= 0; i--) {
    while (ind >= 2 && vect(cv[ind - 2].first, cv[ind - 1].first, pt[i]) < 0)
      ind--;
    add_edge(i, cv[ind - 1].second);
    cv[ind++] = make_pair(pt[i], i);
  }
  init();
  int m;
  scanf("%d", &m);
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d ", LCA(a, b));
  }
  puts("");
  return 0;
}
