#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
const int LG = 20;
int dp[LG][N];
int depth[N];
int n;
int m;
struct point {
  long long x, y, idx;
  point() {}
} M[N];
vector<point> hull;
vector<int> graf[N];
inline void load() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%I64d %I64d", &M[i].x, &M[i].y), M[i].idx = i;
}
inline int ccw(const point &A, const point &B, const point &C) {
  long long a = (long long)A.x * (B.y - C.y) + (long long)B.x * (C.y - A.y) +
                (long long)C.x * (A.y - B.y);
  if (a < 0) return -1;
  if (a > 0) return 1;
  return 0;
}
inline void make_graph() {
  for (int i = 1; i < n; i++) {
    graf[dp[0][i]].push_back(i);
  }
}
void dfs(int x = n, int par = -1, int dub = 0) {
  depth[x] = dub;
  for (int i = 0; i < graf[x].size(); i++) {
    if (graf[x][i] != par) dfs(graf[x][i], x, dub + 1);
  }
}
inline int lca(int x, int y) {
  if (depth[y] > depth[x]) swap(x, y);
  for (int i = LG - 1; i >= 0; i--) {
    if (depth[x] - (1 << i) >= depth[y]) x = dp[i][x];
  }
  if (x == y) return x;
  for (int i = LG - 1; i >= 0; i--) {
    if (dp[i][x] != dp[i][y]) {
      x = dp[i][x];
      y = dp[i][y];
    }
  }
  return dp[0][x];
}
inline void solve() {
  hull.push_back(M[n]);
  for (int i = n - 1; i >= 1; i--) {
    while (hull.size() >= 2 &&
           ccw(hull[hull.size() - 2], hull[hull.size() - 1], M[i]) < 0)
      hull.pop_back();
    dp[0][i] = hull.back().idx;
    hull.push_back(M[i]);
  }
  for (int j = 1; j < LG; j++) {
    for (int i = 1; i <= n; i++) {
      dp[j][i] = dp[j - 1][dp[j - 1][i]];
    }
  }
  make_graph();
  dfs();
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    printf("%d\n", lca(x, y));
  }
}
int main(void) {
  load();
  solve();
  return 0;
}
