#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
inline void writes(string s) { puts(s.c_str()); }
inline void writeln() { writes(""); }
inline void writei(int x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline void writell(long long x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
long long n, m, i, j, px[100005], py[100005], qx[100005], ql, qr,
    fa[100005][19], dep[100005];
long long crs(long long x, long long y, long long xx, long long yy) {
  return x * yy - y * xx;
}
long long crs(long long x, long long y, long long z) {
  return crs(px[y] - px[x], py[y] - py[x], px[z] - px[x], py[z] - py[x]);
}
long long lca(long long x, long long y) {
  long long i;
  for ((i) = (18); (i) >= (0); (i)--)
    if (dep[fa[x][i]] >= dep[y]) x = fa[x][i];
  for ((i) = (18); (i) >= (0); (i)--)
    if (dep[fa[y][i]] >= dep[x]) y = fa[y][i];
  if (x == y) return x;
  for ((i) = (18); (i) >= (0); (i)--)
    if (fa[x][i] != fa[y][i]) {
      x = fa[x][i];
      y = fa[y][i];
    }
  return fa[x][0];
}
int main() {
  read(n);
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    read(px[i]);
    read(py[i]);
  }
  dep[n] = 1;
  qx[ql = qr = 1] = n;
  for (((i)) = ((n - 1)); ((i)) >= (1); ((i))--) {
    while (ql < qr && crs(qx[qr - 1], qx[qr], i) < 0) qr--;
    fa[i][0] = qx[qr];
    dep[i] = dep[qx[qr]] + 1;
    qx[++qr] = i;
  }
  for (((j)) = (1); ((j)) <= ((18)); ((j))++)
    for (((i)) = (1); ((i)) <= ((n)); ((i))++)
      fa[i][j] = fa[fa[i][j - 1]][j - 1];
  read(m);
  while (m--) {
    long long x, y;
    read(x);
    read(y);
    printf("%I64d ", lca(x, y));
  }
  return 0;
}
