#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 - '0' + c, c = getchar();
  x *= f;
}
const int N = 1e5 + 10;
int fa[N][18], dep[N], n;
struct Point {
  long long x, y;
  Point(long long x = 0, long long y = 0) : x(x), y(y) {}
  Point operator-(const Point b) { return Point(x - b.x, y - b.y); }
} pt[N];
long long Cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
int st[N], top;
int query(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int j = 17; j >= 0; j--)
    if (dep[x] - (1 << j) >= dep[y]) x = fa[x][j];
  if (x == y) return x;
  for (int j = 17; j >= 0; j--)
    if (fa[x][j] != fa[y][j]) x = fa[x][j], y = fa[y][j];
  return fa[x][0];
}
int main() {
  int q, x, y;
  read(n);
  for (int i = 1; i <= n; ++i) scanf("%lld%lld", &pt[i].x, &pt[i].y);
  st[++top] = n;
  for (int i = n - 1; i >= 1; --i) {
    while (top > 1 &&
           Cross(pt[st[top]] - pt[i], pt[st[top - 1]] - pt[st[top]]) > 0)
      top--;
    fa[i][0] = st[top], st[++top] = i;
  }
  for (int i = n - 1; i >= 1; i--) {
    dep[i] = dep[fa[i][0]] + 1;
    for (int j = 1; j <= 17; j++) fa[i][j] = fa[fa[i][j - 1]][j - 1];
  }
  read(q);
  while (q--) {
    read(x), read(y);
    printf("%d  ", query(x, y));
  }
  return 0;
}
