#include <bits/stdc++.h>
using namespace std;
const int maxn = 311125;
const int N = 20;
long long x[maxn], y[maxn];
int stk[maxn], top;
struct node {
  int v, next;
} edge[maxn];
int head[maxn], P[maxn][N], e;
void add_edge(int u, int v) {
  edge[e].v = v;
  edge[e].next = head[u];
  head[u] = e++;
}
bool vis[maxn];
int dep[maxn];
void dfs(int u, int fa, int Dep) {
  vis[u] = true;
  P[u][0] = fa;
  dep[u] = Dep;
  int i, v;
  for (i = 1; i < N; ++i) {
    v = P[u][i - 1];
    P[u][i] = P[v][i - 1];
  }
  for (i = head[u]; ~i; i = edge[i].next) {
    v = edge[i].v;
    if (!vis[v]) {
      dfs(v, u, Dep + 1);
    }
  }
}
int jump(int u, int k) {
  for (int i = 0; i < N; ++i) {
    if ((k >> i) & 1) u = P[u][i];
  }
  return u;
}
int LCA(int u, int v) {
  if (dep[u] ^ dep[v]) {
    if (dep[u] < dep[v]) swap(u, v);
    u = jump(u, dep[u] - dep[v]);
  }
  if (u ^ v) {
    for (int i = N - 1; i >= 0; --i) {
      if (P[u][i] ^ P[v][i]) {
        u = P[u][i];
        v = P[v][i];
      }
    }
    u = P[u][0];
  }
  return u;
}
int main() {
  ios::sync_with_stdio(false);
  int n, i;
  cin >> n;
  for (i = 1; i <= n; ++i) {
    cin >> x[i] >> y[i];
  }
  P[n][0] = n;
  memset(head, -1, sizeof(head));
  for (i = n; i >= 1; --i) {
    while (top > 1) {
      int k = stk[top - 1];
      int j = stk[top - 2];
      double t1 = 1.0 * (y[k] - y[i]) / (x[k] - x[i]);
      double t2 = 1.0 * (y[j] - y[k]) / (x[j] - x[k]);
      if (t1 < t2) {
        --top;
      } else {
        break;
      }
    }
    if (top > 0) {
      int u = stk[top - 1];
      add_edge(u, i);
    }
    stk[top++] = i;
  }
  dfs(n, n, 0);
  int m;
  cin >> m;
  for (i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    cout << LCA(u, v) << endl;
  }
  return 0;
}
