#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n, m;
int nex[200000];
pair<long long, long long> a[200000];
int par[200000][20];
int depth[200000];
long long ccw(pair<long long, long long> x, pair<long long, long long> y,
              pair<long long, long long> z) {
  return (y.first - x.first) * (z.second - x.second) -
         (y.second - x.second) * (z.first - x.first);
}
int lca(int x, int y) {
  int i, j;
  if (depth[x] < depth[y]) swap(x, y);
  int cha = depth[x] - depth[y];
  for (i = 0; i < 20; i++) {
    if (cha & (1 << i)) x = par[x][i];
  }
  if (x == y) return x;
  for (i = 19; i >= 0; i--) {
    if (par[x][i] != par[y][i]) x = par[x][i], y = par[y][i];
  }
  return par[x][0];
}
int main() {
  int i, j, k;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%I64d%I64d", &a[i].first, &a[i].second);
  nex[n - 1] = n - 1;
  for (i = n - 2; i >= 0; i--) {
    int dab = i + 1;
    while (1) {
      if (ccw(a[i], a[dab], a[nex[dab]]) > 0) {
        dab = nex[dab];
      } else
        break;
    }
    nex[i] = dab;
  }
  depth[n - 1] = 0;
  for (i = n - 2; i >= 0; i--) depth[i] = depth[nex[i]] + 1;
  for (i = n - 1; i >= 0; i--) {
    par[i][0] = nex[i];
    for (j = 1; j < 20; j++) {
      par[i][j] = par[par[i][j - 1]][j - 1];
    }
  }
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    printf("%d ", lca(x, y) + 1);
  }
  return 0;
}
