#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int n, m, st[MAXN][20], depth[MAXN];
long long xs[MAXN], ys[MAXN];
bool check(int p1, int p2, int p3) {
  long long x1 = xs[p2] - xs[p3];
  long long y1 = ys[p2] - ys[p3];
  long long x2 = xs[p1] - xs[p2];
  long long y2 = ys[p1] - ys[p2];
  return (x1 * y2 - x2 * y1 >= 0);
}
void get_parents() {
  depth[n - 1] = 0;
  st[n - 1][0] = n - 1;
  vector<int> s;
  s.push_back(n - 1);
  for (int i = n - 2; i >= 0; --i) {
    while (s.size() > 1 && !check(i, s.back(), s[s.size() - 2])) {
      s.pop_back();
    }
    depth[i] = depth[s.back()] + 1;
    st[i][0] = s.back();
    s.push_back(i);
  }
}
void build_lca() {
  for (int j = 1; j < 20; ++j) {
    for (int i = 0; i < n; ++i) {
      st[i][j] = st[st[i][j - 1]][j - 1];
    }
  }
}
int query(int a, int b) {
  if (depth[a] < depth[b]) swap(a, b);
  for (int i = 19; i >= 0; --i) {
    if (depth[st[a][i]] >= depth[b]) {
      a = st[a][i];
    }
  }
  if (a == b) return a;
  for (int i = 19; i >= 0; --i) {
    if (st[a][i] != st[b][i]) {
      a = st[a][i];
      b = st[b][i];
    }
  }
  return st[a][0];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> xs[i] >> ys[i];
  }
  get_parents();
  build_lca();
  cin >> m;
  for (int i = 0, a, b; i < m; ++i) {
    cin >> a >> b;
    --a;
    --b;
    printf("%d\n", query(a, b) + 1);
  }
  return 0;
}
