#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
const int Log = 18;
int n, h[N], p[Log][N];
vector<int> g[N], ans;
void pre() {
  for (int i = 1; i < Log; i++)
    for (int j = 0; j < n; j++)
      if (p[i - 1][j] != -1) p[i][j] = p[i - 1][p[i - 1][j]];
}
void dfs(int v, int dep) {
  for (auto x : g[v]) {
    h[x] = h[v] + 1;
    p[0][x] = v;
    dfs(x, dep + 1);
  }
}
int lca(int u, int v) {
  if (h[u] > h[v]) swap(u, v);
  for (int i = Log - 1; i > -1; i--)
    if (p[i][v] != -1 && h[p[i][v]] >= h[u]) v = p[i][v];
  if (u == v) return v;
  for (int i = Log - 1; i > -1; i--)
    if (p[i][u] != -1 && p[i][u] != p[i][v]) u = p[i][u], v = p[i][v];
  return p[0][v];
}
pair<long long, long long> a[N];
long long ri[N];
vector<long long> f, s;
void ok() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%I64d %I64d", &a[i].first, &a[i].second);
  f.push_back(n - 1);
  s.push_back(n - 1);
  ri[n - 1] = -1;
  for (int i = n - 2; i > -1; i--) {
    long long ss = f.size();
    while (f.size() > 1 && (a[i].second - a[f[ss - 2]].second) *
                                   (-a[f[ss - 1]].first + a[f[ss - 2]].first) >
                               (a[f[ss - 1]].second - a[f[ss - 2]].second) *
                                   (-a[i].first + a[f[ss - 2]].first))
      f.pop_back(), ss--;
    ss = s.size();
    while (ss > 1 && (a[i].second - a[s[ss - 2]].second) *
                             (-a[s[ss - 1]].first + a[s[ss - 2]].first) >
                         (a[s[ss - 1]].second - a[s[ss - 2]].second) *
                             (-a[i].first + a[s[ss - 2]].first))
      s.pop_back(), ss--;
    ri[i] = max(s.back(), f.back());
    f.push_back(i);
    s.push_back(i);
  }
  for (int i = 0; i < n - 1; i++) g[ri[i]].push_back(i);
}
int main() {
  memset(p, -1, sizeof(p));
  ok();
  dfs(n - 1, 0);
  pre();
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d %d", &a, &b);
    ans.push_back(lca(--a, --b) + 1);
  }
  for (auto x : ans) printf("%d ", x);
}
