#include <bits/stdc++.h>
using namespace std;
bool debug = 1;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
long long x[100005], y[100005];
int nxt[100005];
vector<int> mp[100005];
int p[100005][20], d[100005];
void init() {
  for (int j = 1; (1 << j) <= n; j++)
    for (int i = 1; i <= n; i++) p[i][j] = p[p[i][j - 1]][j - 1];
}
int lca(int a, int b) {
  if (d[a] > d[b]) swap(a, b);
  int f = d[b] - d[a];
  for (int i = 0; (1 << i) <= f; i++)
    if ((1 << i) & f) b = p[b][i];
  if (a != b) {
    for (int i = (int)log2(n); i >= 0; i--)
      if (p[a][i] != p[b][i]) {
        a = p[a][i];
        b = p[b][i];
      }
    a = p[a][0];
  }
  return a;
}
void dfs(int x, int pa, int dp) {
  d[x] = dp;
  p[x][0] = pa;
  for (int c : mp[x]) dfs(c, x, dp + 1);
}
void cal() {
  for (int(i) = 1; (i) <= (int)(n - 1); (i)++) {
    mp[nxt[i]].push_back(i);
  }
  dfs(n, 0, 1);
  init();
  scanf("%d", &m);
  for (int a, b, i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    printf("%d ", lca(a, b));
  }
}
int main() {
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%lld%lld", x + i, y + i);
  }
  nxt[n] = n;
  for (int i = n - 1; i; i--) {
    nxt[i] = i + 1;
    while (1) {
      int p = nxt[i];
      if (p == n) break;
      int q = nxt[p];
      long long l =
          (y[q] - y[i]) * x[p] + y[i] * (x[q] - x[i]) - x[i] * (y[q] - y[i]);
      long long r = (x[q] - x[i]) * y[p];
      if (l > r) {
        nxt[i] = q;
      } else
        break;
    }
  }
  cal();
  return 0;
}
