#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100000;
const int BN = 17;
template <typename T>
struct Pt {
  T x, y;
  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt<T> &pt) : x(pt.x), y(pt.y) {}
  Pt<T> operator+(const Pt<T> pt) const { return Pt<T>(x + pt.x, y + pt.y); }
  Pt<T> operator-() const { return Pt<T>(-x, -y); }
  Pt<T> operator-(const Pt<T> pt) const { return Pt<T>(x - pt.x, y - pt.y); }
  Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
  Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
  T dot(Pt<T> v) const { return x * v.x + y * v.y; }
  T cross(Pt<T> v) const { return x * v.y - y * v.x; }
};
struct Elm {
  Pt<long long> v;
  int i;
  Elm() {}
  Elm(Pt<long long> _v, int _i) : v(_v), i(_i) {}
};
Pt<long long> hs[MAX_N];
Elm q[MAX_N];
int ds[MAX_N], ps[MAX_N][BN];
int lca(int u, int v) {
  if (ds[u] > ds[v]) swap(u, v);
  for (int k = BN - 1; k >= 0; k--)
    if (((ds[v] - ds[u]) >> k) & 1) v = ps[v][k];
  if (u == v) return u;
  for (int k = BN - 1; k >= 0; k--)
    if (ps[u][k] != ps[v][k]) u = ps[u][k], v = ps[v][k];
  return ps[u][0];
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lld%lld", &hs[i].x, &hs[i].y);
  int qp = 0;
  q[0] = Elm(Pt<long long>(0, -1), n - 1);
  ps[n - 1][0] = -1, ds[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    for (;; qp--) {
      Elm e = q[qp];
      Pt<long long> v(hs[e.i] - hs[i]);
      if (v.cross(e.v) <= 0) {
        q[++qp] = Elm(v, i);
        ps[i][0] = e.i, ds[i] = ds[e.i] + 1;
        break;
      }
    }
  }
  for (int k = 0; k < BN - 1; k++)
    for (int i = 0; i < n; i++)
      ps[i][k + 1] = (ps[i][k] >= 0) ? ps[ps[i][k]][k] : -1;
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    int c = lca(a, b);
    if (i) putchar(' ');
    printf("%d", c + 1);
  }
  putchar('\n');
  return 0;
}
