#include <bits/stdc++.h>
using namespace std;
int n;
int q[100010], h, t;
int dep[100010], fa[100010][19];
long long a[100010][2];
void Init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%I64d%I64d", &a[i][0], &a[i][1]);
}
inline bool Check(int i, int j, int x, int y) {
  return (a[j][1] - a[i][1]) * (a[y][0] - a[x][0]) >
         (a[y][1] - a[x][1]) * (a[j][0] - a[i][0]);
}
void Work() {
  dep[n] = 1;
  h = 100001, t = 100000;
  int l, r, mid;
  for (int i = n - 1; i >= 1; --i) {
    while (t - h + 1 >= 2 && !Check(i + 1, q[h], q[h], q[h + 1])) ++h;
    q[--h] = i + 1;
    l = h;
    r = t;
    while (l < r) {
      mid = (l + r + 1) >> 1;
      if (Check(i, q[mid], i, q[mid - 1]))
        l = mid;
      else
        r = mid - 1;
    }
    fa[i][0] = q[l];
    dep[i] = dep[fa[i][0]] + 1;
  }
  for (int j = 1; j <= 18; ++j)
    for (int i = 1; i <= n; ++i) fa[i][j] = fa[fa[i][j - 1]][j - 1];
}
inline int Lca(int u, int v) {
  if (dep[v] < dep[u]) swap(u, v);
  for (int i = 18; i >= 0; --i)
    if (dep[fa[v][i]] > dep[u]) v = fa[v][i];
  if (dep[u] != dep[v]) v = fa[v][0];
  for (int i = 18; i >= 0; --i)
    if (fa[u][i] != fa[v][i]) u = fa[u][i], v = fa[v][i];
  if (u != v) u = fa[u][0];
  return u;
}
void Solve() {
  int Q, u, v;
  scanf("%d", &Q);
  while (Q--) {
    scanf("%d%d", &u, &v);
    printf("%d", Lca(u, v));
    if (Q)
      printf(" ");
    else
      printf("\n");
  }
}
int main() {
  Init();
  Work();
  Solve();
  return 0;
}
