#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int MOD = 1000000007;
map<long long, int> R;
double x[100024], y[100024];
int fa[100024], dp[100024][20];
vector<int> e[100024];
const int M = 17;
int dep[100024];
void dfs(int u, int par, int h = 0) {
  dp[u][0] = par;
  dep[u] = h;
  for (int i = 1; i <= M; i++) dp[u][i] = dp[dp[u][i - 1]][i - 1];
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i];
    dfs(v, u, h + 1);
  }
}
int find(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  int dif = dep[u] - dep[v];
  for (int i = 0; i <= M; i++)
    if (dif & (1 << i)) {
      u = dp[u][i];
    }
  if (u != v) {
    for (int i = M; i >= 0; i--) {
      if (dp[u][i] != dp[v][i]) {
        u = dp[u][i], v = dp[v][i];
      }
    }
    u = dp[u][0];
  }
  return u;
}
double cal(int i, int j) { return (y[j] - y[i]) / (x[j] - x[i]); }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lf %lf", &x[i], &y[i]);
  }
  int p = n;
  fa[n] = n;
  for (int i = n - 1; i >= 1; i--) {
    int a = i + 1, b = fa[i + 1];
    while (cal(i, a) < cal(i, b)) {
      a = b;
      b = fa[b];
    }
    fa[i] = a;
    e[a].push_back(i);
  }
  dfs(n, n);
  int m;
  scanf("%d", &m);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    printf("%d ", find(u, v));
  }
  return 0;
}
