#include <bits/stdc++.h>
long long y[100000];
int a[16 + 1][100000], x[100000], n, m, i, j, xx, yy;
bool lp(int xx, int yy, int zz) {
  return (y[zz] - y[xx]) * (x[yy] - x[xx]) > (y[yy] - y[xx]) * (x[zz] - x[xx]);
}
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d%I64d", &x[i], &y[i]);
  a[0][n - 1] = n - 1;
  a[0][n - 2] = n - 1;
  for (i = n - 3; i >= 0; --i) {
    xx = i + 1;
    while (xx != a[0][xx] && lp(i, xx, a[0][xx])) xx = a[0][xx];
    a[0][i] = xx;
  }
  x[n - 1] = 0;
  for (i = n - 2; i >= 0; --i) x[i] = x[a[0][i]] + 1;
  for (i = n - 2; i >= 0; --i)
    for (j = 1; j <= 16; ++j) a[j][i] = a[j - 1][a[j - 1][i]];
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d", &xx, &yy);
    --xx, --yy;
    if (x[xx] < x[yy]) i = xx, xx = yy, yy = i;
    for (i = x[xx] - x[yy], j = 16; i; --j)
      if (i >= 1 << j) xx = a[j][xx], i = x[xx] - x[yy];
    for (j = 16; j >= 0 && xx != yy; --j)
      if (a[j][xx] != a[j][yy]) xx = a[j][xx], yy = a[j][yy];
    printf("%d ", xx == yy ? xx + 1 : a[0][xx] + 1);
  }
  return 0;
}
