#include <bits/stdc++.h>
using namespace std;
int n, m;
int a, b;
int x[100000];
long long y[100000];
int fa[100000], l[1000000];
vector<vector<int> > node;
int dp[100000][18];
bool check(int i, int j, int k) {
  return ((x[j] - x[i]) * (y[k] - y[j]) - (x[k] - x[j]) * (y[j] - y[i])) > 0LL;
}
void LCA_preprocess() {
  for (int i = 0; i < n; ++i)
    for (int j = 0; (1 << j) < n; ++j) dp[i][j] = -1;
  for (int i = 0; i < n; ++i) dp[i][0] = fa[i];
  for (int j = 1; (1 << j) < n; ++j)
    for (int i = 0; i < n; ++i)
      if (dp[i][j - 1] != -1) dp[i][j] = dp[dp[i][j - 1]][j - 1];
}
void dfs(int cur, int prev, int level) {
  l[cur] = level;
  for (int i = 0; i < node[cur].size(); ++i)
    if (node[cur][i] != prev) dfs(node[cur][i], cur, level + 1);
}
int LCA_query(int a, int b) {
  if (l[a] < l[b]) {
    int tmp = a;
    a = b;
    b = tmp;
  }
  int log;
  for (log = 1; (1 << log) <= l[a]; ++log)
    ;
  --log;
  for (int i = log; i >= 0; --i)
    if (l[a] - (1 << i) >= l[b]) a = dp[a][i];
  if (a == b) return a;
  for (int i = log; i >= 0; --i)
    if (dp[a][i] != -1 && dp[a][i] != dp[b][i]) {
      a = dp[a][i];
      b = dp[b][i];
    }
  return fa[a];
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%I64d", &x[i], &y[i]);
    vector<int> v;
    node.push_back(v);
  }
  for (int i = n - 1; i >= 0; --i) {
    if (i == n - 1)
      fa[i] = -1;
    else {
      int tmpRightMost = i + 1;
      while (fa[tmpRightMost] != -1 && check(i, tmpRightMost, fa[tmpRightMost]))
        tmpRightMost = fa[tmpRightMost];
      fa[i] = tmpRightMost;
      node[tmpRightMost].push_back(i);
    }
  }
  LCA_preprocess();
  dfs(n - 1, -1, 0);
  vector<int> ans;
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &a, &b);
    a--;
    b--;
    int c = LCA_query(a, b);
    ans.push_back(c + 1);
  }
  printf("%d", ans[0]);
  for (int i = 1; i < m; ++i) printf(" %d", ans[i]);
  return 0;
}
