#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
const int MAXLOGN = 18;
int N;
complex<long long> P[MAXN];
int H[MAXN];
int jmp[MAXN][MAXLOGN];
int dep[MAXN];
long long cross(complex<long long> a, complex<long long> b) {
  return imag(conj(a) * b);
}
void find_hull() {
  int sz = 0;
  for (int i = N - 1; i >= 0; i--) {
    while (sz >= 2 &&
           cross(P[H[sz - 2]] - P[H[sz - 1]], P[i] - P[H[sz - 1]]) > 0)
      sz--;
    H[sz] = i;
    if (sz > 0) {
      jmp[i][0] = H[sz - 1];
      dep[i] = dep[jmp[i][0]] + 1;
    } else
      jmp[i][0] = i;
    sz++;
  }
}
void process() {
  for (int i = 0; i < N; i++)
    for (int j = 1; j < MAXLOGN; j++) jmp[i][j] = N - 1;
  for (int j = 1; (1 << j) < N; j++)
    for (int i = 0; i < N; i++) jmp[i][j] = jmp[jmp[i][j - 1]][j - 1];
}
int query(int a, int b) {
  if (dep[a] > dep[b]) swap(a, b);
  for (int i = MAXLOGN - 1; i >= 0; i--)
    if (dep[jmp[b][i]] >= dep[a]) b = jmp[b][i];
  if (a == b) return a;
  for (int i = MAXLOGN - 1; i >= 0; i--)
    if (jmp[a][i] != jmp[b][i]) {
      a = jmp[a][i];
      b = jmp[b][i];
    }
  return jmp[a][0];
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    long long xi, yi;
    cin >> xi >> yi;
    P[i] = complex<long long>(xi, yi);
  }
  find_hull();
  process();
  int M;
  cin >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    cout << query(a - 1, b - 1) + 1 << "\n";
  }
  return 0;
}
