#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1111111;
struct Point {
  int x;
  long long y;
  Point(int x = 0, long long y = 0) : x(x), y(y) {}
  Point operator-(const Point &b) const { return Point(x - b.x, y - b.y); }
  long long operator*(const Point &b) const { return x * b.y - y * b.x; }
} A[MaxN], Stack[MaxN];
int who[MaxN], dep[MaxN], father[22][111111];
int lca(int x, int y) {
  if (dep[x] > dep[y]) swap(x, y);
  for (int i = 20; i >= 0; --i)
    if (dep[father[i][y]] >= dep[x]) y = father[i][y];
  if (x == y) return x;
  for (int i = 20; i >= 0; --i)
    if (father[i][x] != father[i][y]) {
      x = father[i][x], y = father[i][y];
    }
  return father[0][x];
}
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) scanf("%d%I64d", &A[i].x, &A[i].y);
  int Top = 0;
  for (int i = n; i >= 1; --i) {
    while (Top > 1) {
      if ((A[i] - Stack[Top]) * (Stack[Top] - Stack[Top - 1]) > 0)
        --Top;
      else
        break;
    }
    father[0][i] = who[Top];
    Stack[++Top] = A[i];
    who[Top] = i;
    dep[i] = dep[father[0][i]] + 1;
  }
  for (int T = 1; T <= 20; ++T)
    for (int i = 1; i <= n; ++i) father[T][i] = father[T - 1][father[T - 1][i]];
  int Q;
  cin >> Q;
  for (int i = 1; i <= Q; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    int ans = lca(x, y);
    printf("%d ", ans);
  }
  puts("");
  return 0;
}
