#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  scanf("%d", &n);
  vector<double> X(n), Y(n);
  for (int i = 0; i < (n); i++) scanf("%lf %lf", &X[i], &Y[i]);
  int m;
  scanf("%d", &m);
  vector<int> A(m), B(m);
  for (int i = 0; i < (m); i++) scanf("%d %d", &A[i], &B[i]);
  for (int i = 0; i < (m); i++) A[i]--;
  for (int i = 0; i < (m); i++) B[i]--;
  vector<int> P(n);
  P[n - 1] = n - 1;
  stack<pair<double, int>> K{};
  K.push({-100000000000000, n - 1});
  for (int i = n - 2; i >= 0; i--) {
    auto p = K.top();
    while ((Y[p.second] - Y[i]) / (X[p.second] - X[i]) <=
           p.first - 0.000000001) {
      K.pop();
      p = K.top();
    }
    P[i] = p.second;
    K.push({(Y[p.second] - Y[i]) / (X[p.second] - X[i]), i});
  }
  vector<vector<int>> AN(20, vector<int>(n));
  for (int i = 0; i < (n); i++) AN[0][i] = P[i];
  for (int j = 1; j <= 19; j++) {
    for (int i = 0; i < (n); i++) {
      AN[j][i] = AN[j - 1][AN[j - 1][i]];
    }
  }
  vector<vector<int>> C(n, vector<int>{});
  for (int i = 0; i < (n); i++) C[P[i]].push_back(i);
  vector<int> D(n);
  D[n - 1] = 1;
  for (int i = n - 2; i >= 0; i--) {
    D[i] = D[P[i]] + 1;
  }
  for (int i = 0; i < (m); i++) {
    int a = A[i];
    int b = B[i];
    if (D[b] > D[a]) swap(a, b);
    if (D[a] > D[b]) {
      int diff = D[a] - D[b];
      for (int j = 19; j >= 0; j--) {
        if ((1 << j) <= diff) {
          a = AN[j][a];
          diff -= (1 << j);
        }
      }
    }
    for (int i = 19; i >= 0; i--) {
      int na = AN[i][a];
      int nb = AN[i][b];
      if (na != nb) {
        a = na;
        b = nb;
      }
    }
    if (a != b) {
      printf("%d ", AN[0][a] + 1);
    } else {
      printf("%d ", a + 1);
    }
  }
}
