#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const long long LINF = 1LL << 60;
const double inf = 1e15;
long long mod = 1e9 + 7;
char READ_DATA;
int SIGNAL_INPUT;
template <typename Type>
inline Type ru(Type &v) {
  SIGNAL_INPUT = 1;
  while ((READ_DATA = getchar()) < '0' || READ_DATA > '9')
    if (READ_DATA == '-')
      SIGNAL_INPUT = -1;
    else if (READ_DATA == EOF)
      return EOF;
  v = READ_DATA - '0';
  while ((READ_DATA = getchar()) >= '0' && READ_DATA <= '9')
    v = v * 10 + READ_DATA - '0';
  v *= SIGNAL_INPUT;
  return v;
}
inline long long modru(long long &v) {
  long long p = 0;
  SIGNAL_INPUT = 1;
  while ((READ_DATA = getchar()) < '0' || READ_DATA > '9')
    if (READ_DATA == '-')
      SIGNAL_INPUT = -1;
    else if (READ_DATA == EOF)
      return EOF;
  p = v = READ_DATA - '0';
  while ((READ_DATA = getchar()) >= '0' && READ_DATA <= '9') {
    v = (v * 10 + READ_DATA - '0') % mod;
    p = (p * 10 + READ_DATA - '0') % (mod - 1);
  }
  v *= SIGNAL_INPUT;
  return p;
}
template <typename A, typename B>
inline char ru(A &x, B &y) {
  if (ru(x) == EOF) return EOF;
  ru(y);
  return 2;
}
template <typename A, typename B, typename C>
inline char ru(A &x, B &y, C &z) {
  if (ru(x) == EOF) return EOF;
  ru(y);
  ru(z);
  return 3;
}
template <typename A, typename B, typename C, typename D>
inline char ru(A &x, B &y, C &z, D &w) {
  if (ru(x) == EOF) return EOF;
  ru(y);
  ru(z);
  ru(w);
  return 4;
}
struct Edge {
  int u, v, next;
  long long w, cap, flow;
  Edge(int _u = 0, int _v = 0, int nxt = -1, long long _w = 1,
       long long _cap = 0) {
    u = _u;
    v = _v;
    w = _w;
    cap = _cap;
    flow = 0;
    next = nxt;
  }
  int operator<(const Edge &b) const { return w < b.w; }
};
const int maxn = 1e5 + 5, N = 2e6 + 1;
double eps = 1e-7, pi = acos(-1.0);
unsigned long long seed = 131, smod = (1LL << 32) - 267;
struct point {
  double x, y;
  point(double _x = 0, double _y = 0) {
    x = _x;
    y = _y;
  }
  point operator-(point &b) { return point(x - b.x, y - b.y); }
  int operator<(point &b) const {
    return x < b.x || (abs(x - b.x) < eps && y < b.y);
  }
  int operator==(point &b) const {
    return abs(x - b.x) < eps && abs(y - b.y) < eps;
  }
};
double cross(point a, point b) { return a.x * b.y - b.x * a.y; }
point a[maxn];
int stk[maxn], top;
int n, m;
Edge edg[maxn];
int ecnt, g[maxn], dep[maxn], p[maxn][17];
void build() {
  stk[++top] = n;
  for (register int i = n - 1; i > 0; --i) {
    while (top > 1 &&
           cross(a[stk[top]] - a[stk[top - 1]], a[i] - a[stk[top]]) < -eps)
      --top;
    edg[++ecnt] = Edge(stk[top], i, g[stk[top]]), g[stk[top]] = ecnt;
    p[i][0] = stk[top];
    stk[++top] = i;
  }
}
void dfs(int u, int fa) {
  for (int j = 1; dep[u] >> j; ++j) {
    p[u][j] = p[p[u][j - 1]][j - 1];
  }
  for (register int i = g[u]; ~i; i = edg[i].next) {
    int &v = edg[i].v;
    if (v != fa) {
      dep[v] = dep[u] + 1;
      dfs(v, u);
    }
  }
}
int LCA(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (register int j = 16; j >= 0; --j)
    if (p[u][j] && dep[p[u][j]] >= dep[v]) u = p[u][j];
  if (u == v) return u;
  for (register int j = 16; j >= 0; --j)
    if (p[u][j] != p[v][j]) {
      u = p[u][j];
      v = p[v][j];
    }
  return p[u][0];
}
int main() {
  memset(g, ecnt = -1, sizeof(g));
  ru(n);
  for (register int i = 1; i <= n; ++i) ru(a[i].x, a[i].y);
  build();
  dfs(n, 0);
  ru(m);
  int u, v;
  while (m--) {
    ru(u, v);
    printf("%d ", LCA(u, v));
  }
}
