#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
struct point {
  ll x, y;
  point() {}
  point(ll xx, ll yy) : x(xx), y(yy) {}
  point operator-(const point& p) const { return point(x - p.x, y - p.y); }
};
ll cross(const point& a, const point& b) { return a.x * b.y - a.y * b.x; }
const int N = 100010, LOGN = 19;
point p[N];
int pa[N][LOGN];
int depth[N];
int lca(int a, int b) {
  if (depth[a] != depth[b]) {
    if (depth[a] > depth[b]) swap(a, b);
    int diff = depth[b] - depth[a];
    for (int i = 0; diff >> i; i++) {
      if ((diff >> i) & 1) b = pa[b][i];
    }
  }
  if (a == b) return a;
  for (int i = LOGN - 1; i >= 0; i--) {
    if (pa[a][i] != pa[b][i]) {
      a = pa[a][i];
      b = pa[b][i];
    }
  }
  return pa[a][0];
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld %lld", &p[i].x, &p[i].y);
  vector<point> v;
  vector<int> id;
  v.push_back(p[n]);
  id.push_back(n);
  int s = 1;
  for (int i = n - 1; i >= 1; i--) {
    while (s > 1 and cross(v[s - 1] - p[i], v[s - 2] - v[s - 1]) > 0) {
      v.pop_back();
      id.pop_back();
      s--;
    }
    pa[i][0] = id.back();
    depth[i] = depth[id.back()] + 1;
    v.push_back(p[i]);
    id.push_back(i);
    s++;
  }
  for (int i = 1; i < LOGN; i++) {
    for (int u = 1; u <= n; u++) pa[u][i] = pa[pa[u][i - 1]][i - 1];
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d%c", lca(a, b), " \n"[!q]);
  }
  return 0;
}
