#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
long long X[maxn], Y[maxn];
vector<int> G[maxn];
int fa[maxn], anc[maxn][25], dep[maxn], q[maxn];
bool vis[maxn];
void init(int n) {
  for (int i = 0; i <= n; i++) G[i].clear();
}
void dfs(int u, int d) {
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (!vis[v]) {
      vis[v] = 1;
      dep[v] = d;
      fa[v] = u;
      dfs(v, d + 1);
    }
  }
}
void RMQ(int n) {
  memset(anc, 0, sizeof(anc));
  for (int i = 1; i <= n; i++) anc[i][0] = fa[i];
  for (int k = 1; k <= 20; k++)
    for (int v = 1; v <= n; v++) anc[v][k] = anc[anc[v][k - 1]][k - 1];
}
int swim(int x, int H) {
  for (int i = 0; H > 0; i++) {
    if (H & 1) x = anc[x][i];
    H /= 2;
  }
  return x;
}
int LCA(int u, int v) {
  int k;
  if (dep[u] > dep[v]) swap(u, v);
  v = swim(v, dep[v] - dep[u]);
  if (u == v) return v;
  while (1) {
    for (k = 0; anc[u][k] != anc[v][k]; k++)
      ;
    if (k == 0) return anc[u][0];
    u = anc[u][k - 1];
    v = anc[v][k - 1];
  }
}
int main() {
  int n, m, x, y;
  while (scanf("%d", &n) != EOF) {
    init(n);
    for (int i = 1; i <= n; i++) scanf("%I64d%I64d", &X[i], &Y[i]);
    q[0] = n;
    int s = 0;
    for (int i = n - 1; i >= 1; i--) {
      while (s && (Y[i] - Y[q[s]]) * (X[q[s - 1]] - X[q[s]]) >
                      (X[q[s]] - X[i]) * (Y[q[s]] - Y[q[s - 1]]))
        s--;
      s++;
      q[s] = i;
      G[q[s - 1]].push_back(i);
    }
    memset(vis, 0, sizeof(vis));
    vis[n] = 1;
    fa[n] = 0;
    dep[n] = 1;
    dfs(n, 2);
    RMQ(n);
    scanf("%d", &m);
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &x, &y);
      int ans = LCA(x, y);
      if (i != m)
        printf("%d ", ans);
      else
        printf("%d", ans);
    }
    printf("\n");
  }
  return 0;
}
