#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T bpow(T p, T e) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
int toInt(string s) {
  int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int toLlint(string s) {
  long long int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int n;
long long int x[100005], y[100005];
long long int a[100005];
int p[100005][25];
int dst[100005];
long long int sum(int i, int j, int k) {
  long long int q;
  q = x[j] * y[i] - y[j] * x[i];
  q += x[k] * y[j] - y[k] * x[j];
  q += x[i] * y[k] - y[i] * x[k];
  return q;
}
void dstq(int x) {
  stack<int> q;
  q.push(x);
  while (p[q.top()][0] != -1 && dst[q.top()] == 0) {
    q.push(p[q.top()][0]);
  }
  q.pop();
  while (!q.empty()) {
    dst[q.top()] = dst[p[q.top()][0]] + 1;
    q.pop();
  }
}
int getLCA(int a, int b) {
  int i, log;
  if (dst[a] < dst[b]) swap(a, b);
  for (log = 1; (1 << log) <= dst[a]; log++)
    ;
  log--;
  for (i = log; i >= 0; i--)
    if (dst[a] - (1 << i) >= dst[b]) a = p[a][i];
  if (a == b) return a;
  for (i = log; i >= 0; i--) {
    if (p[a][i] != -1 && p[a][i] != p[b][i]) {
      a = p[a][i];
      b = p[b][i];
    }
  }
  return p[a][0];
}
int main() {
  int t, i, j, k;
  memset(p, -1, sizeof(p));
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%lld%lld", &x[i], &y[i]);
    p[i][0] = i + 1;
  }
  p[i - 1][0] = -1;
  for (i = n - 2; i > -1; i--) {
    while (p[i][0] != -1 && p[p[i][0]][0] != -1 &&
           sum(i, p[i][0], p[p[i][0]][0]) < 0LL) {
      p[i][0] = p[p[i][0]][0];
    }
  }
  dst[n - 1] = 0;
  for (i = 0; i < n - 1; i++) {
    if (dst[i] == 0) dstq(i);
  }
  for (i = 1; (1 << i) <= n; i++) {
    for (j = 0; j < n; j++) {
      if (p[j][i - 1] != -1) p[j][i] = p[p[j][i - 1]][i - 1];
    }
  }
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &i, &j);
    printf("%d ", getLCA(i - 1, j - 1) + 1);
  }
  return 0;
}
