#include <bits/stdc++.h>
using namespace std;
int n, m;
int x[100001];
long long y[100001];
int d[100001];
int up[20][100001];
bool cansee(int i, int j, int k) {
  return (x[j] - x[i]) * (y[k] - y[i]) - (x[k] - x[i]) * (y[j] - y[i]) > 0;
}
int lca(int a, int b) {
  if (d[a] > d[b]) swap(a, b);
  for (int i = 19; i >= 0; --i) {
    if (d[up[i][b]] >= d[a]) b = up[i][b];
  }
  if (a == b) return a;
  for (int i = 19; i >= 0; --i) {
    if (up[i][a] != up[i][b]) {
      a = up[i][a];
      b = up[i][b];
    }
  }
  return up[0][a];
}
int main() {
  scanf("%d", &n);
  for (int _n(n), i(0); i < _n; i++) scanf("%d%I64d", x + i, y + i);
  d[n - 1] = 0;
  up[0][n - 1] = n - 1;
  for (int i = n - 2; i >= 0; --i) {
    up[0][i] = i + 1;
    for (;;) {
      int nxt = up[0][i];
      int nnxt = up[0][nxt];
      if (nxt == nnxt) break;
      if (cansee(i, nxt, nnxt))
        up[0][i] = nnxt;
      else
        break;
    }
    d[i] = d[up[0][i]] + 1;
  }
  for (int _n(20), i(1); i < _n; i++)
    for (int _n(n), j(0); j < _n; j++) up[i][j] = up[i - 1][up[i - 1][j]];
  scanf("%d", &m);
  for (int _n(m), i(0); i < _n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    if (i) printf(" ");
    printf("%d", lca(a, b) + 1);
  }
  puts("");
  return 0;
}
