#include <bits/stdc++.h>
using namespace std;
ifstream fi("406D.INP");
ofstream fo("406D.OUT");
struct Tpoint {
  long long x, y;
};
vector<int> c[100010];
Tpoint a[100010];
int n, s[100010], h[100010], q[100010];
int cha[100010], par[20][100010];
bool datham[100010];
bool cmp(Tpoint X, Tpoint Y) { return X.x < Y.x; }
void nhapdl() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%I64d%I64d", &a[i].x, &a[i].y);
}
int CCW(Tpoint p1, Tpoint p2, Tpoint p3) {
  int64_t a1 = p2.x - p1.x, a2 = p2.y - p1.y, b1 = p3.x - p2.x,
          b2 = p3.y - p2.y, t = a1 * b2 - a2 * b1;
  if (t == 0)
    return 0;
  else if (t < 0)
    return 1;
  return -1;
}
void taocay() {
  int fr = 2;
  s[1] = n;
  s[2] = n - 1;
  c[n].push_back(n - 1);
  cha[n - 1] = n;
  for (int i = n - 2; i >= 1; --i) {
    while (CCW(a[i], a[s[fr]], a[s[fr - 1]]) < 0 && fr > 1) --fr;
    s[++fr] = i;
    cha[i] = s[fr - 1];
    c[s[fr - 1]].push_back(i);
  }
}
void BFS() {
  int dau = 1, cuoi = 1;
  q[1] = n;
  while (dau <= cuoi) {
    int u = q[dau];
    par[0][u] = cha[u];
    for (int i = 1; i <= 18; ++i)
      if (par[i - 1][u] != 0) par[i][u] = par[i - 1][par[i - 1][u]];
    for (int i = 0; i < c[u].size(); ++i)
      if (!datham[c[u][i]]) {
        datham[c[u][i]] = true;
        h[c[u][i]] = h[u] + 1;
        q[++cuoi] = c[u][i];
      }
    ++dau;
  }
}
int LCA(int u, int v) {
  int x = h[u] - h[v];
  if (x < 0) x = -x;
  for (int i = 17; i >= 0; --i)
    if (x >> i & 1) {
      if (h[u] > h[v])
        u = par[i][u];
      else
        v = par[i][v];
    }
  if (u == v) return u;
  for (int i = 17; i >= 0; --i)
    if (par[i][u] != par[i][v]) u = par[i][u], v = par[i][v];
  return cha[u];
}
void xuli() {
  int Q;
  scanf("%d", &Q);
  for (int i = 1; i <= Q; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    printf("%d ", LCA(u, v));
  }
}
int main() {
  nhapdl();
  taocay();
  BFS();
  xuli();
}
