#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, par[100007][20], h[100007];
struct hill {
  long long x, y;
};
hill h1[100007];
int izvinite_tacke_nisam_tako_mislio(int i, int j, int k) {
  return (((h1[k].x - h1[i].x) * (h1[j].y - h1[i].y) -
           (h1[k].y - h1[i].y) * (h1[j].x - h1[i].x)) < 0);
}
int lca(int u, int v) {
  if (h[u] < h[v]) swap(u, v);
  int raz = h[u] - h[v];
  for (int i = 0; i < 20; i++) {
    if (raz & (1 << i)) u = par[u][i];
  }
  if (u == v) return u;
  for (int i = 19; i >= 0; i--) {
    if (par[v][i] != par[u][i]) {
      v = par[v][i];
      u = par[u][i];
    }
  }
  return par[u][0];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d%I64d", &h1[i].x, &h1[i].y);
  vector<int> second;
  second.push_back(n);
  for (int i = n - 1; i; i--) {
    while (second.size() >= 2 &&
           izvinite_tacke_nisam_tako_mislio(i, second.back(),
                                            second[second.size() - 2]))
      second.pop_back();
    par[i][0] = second.back();
    h[i] = h[second.back()] + 1;
    second.push_back(i);
  }
  for (int i = 1; i <= 19; i++)
    for (int j = 1; j <= n; j++) par[j][i] = par[par[j][i - 1]][i - 1];
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d", &a, &b);
    printf("%d ", lca(a, b));
  }
  return 0;
}
