#include <bits/stdc++.h>
using namespace std;
void _fill_int(int* p, int val, int rep) {
  int i;
  for (i = 0; i < rep; i++) p[i] = val;
}
signed long long GETi() {
  signed long long i;
  scanf("%lld", &i);
  return i;
}
int N;
signed long long X[100001], Y[100001];
int depth[100001];
int Q;
int tar[21][1 << 20];
int proc(int y, int step) {
  int i;
  for (i = 0; i < 20; i++)
    if (step & (1 << i)) y = tar[i][y];
  return y;
}
int dist(int x, int y) {
  int res = 0, i;
  if (depth[x] < depth[y]) swap(x, y);
  x = proc(x, depth[x] - depth[y]);
  if (x == y) return x;
  int mi = N - 1;
  for (i = 19; i >= 0; i--) {
    if (tar[i][x] == tar[i][y]) mi = min(mi, tar[i][x]);
    if (tar[i][x] != tar[i][y]) x = tar[i][x], y = tar[i][y];
  }
  return mi;
}
void solve() {
  int f, i, j, k, l, x, y;
  cin >> N;
  int xx;
  for (i = 0; i < N; i++) cin >> X[i] >> Y[i];
  for (i = 0; i < N; i++) tar[0][i] = i + 1;
  tar[0][N - 1] = N - 1;
  vector<int> V;
  V.push_back(N - 1);
  for (i = N - 2; i >= 0; i--) {
    while (V.size() >= 2) {
      int j = V[V.size() - 1], k = V[V.size() - 2];
      if ((X[j] - X[i]) * (Y[k] - Y[i]) <= (X[k] - X[i]) * (Y[j] - Y[i])) break;
      V.pop_back();
    }
    tar[0][i] = V[V.size() - 1];
    V.push_back(i);
  }
  for (x = 0; x < 20; x++) {
    for (i = 0; i < N; i++) tar[x + 1][i] = tar[x][tar[x][i]];
  }
  for (i = N - 2; i >= 0; i--) depth[i] = depth[tar[0][i]] + 1;
  cin >> Q;
  while (Q--) {
    cin >> x >> y;
    (void)printf("%d ", dist(x - 1, y - 1) + 1);
  }
  (void)printf("\n");
}
int main(int argc, char** argv) {
  string s;
  if (argc == 1) ios::sync_with_stdio(false);
  for (int i = 1; i < argc; i++) s += argv[i], s += '\n';
  for (int i = s.size() - 1; i >= 0; i--) ungetc(s[i], stdin);
  solve();
  return 0;
}
