#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
template <class T>
inline int chkmin(T& a, const T& val) {
  return a > val ? a = val, 1 : 0;
}
template <class T>
inline int chkmax(T& a, const T& val) {
  return a < val ? a = val, 1 : 0;
}
inline long long isqrt(long long k) {
  long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
const int maxn = 100010;
const int maxe = 20;
int n, m;
long long x[maxn];
long long y[maxn];
int nxt[maxn][maxe];
long long cross(long long x, long long y, long long z, long long w) {
  return x * w - y * z;
}
int check(int u, int v) {
  for (int i = (maxe)-1; i >= (0); i--) {
    if (nxt[u][i] <= v) {
      u = nxt[u][i];
    }
  }
  return u == v;
}
void solve() {
  cin >> n;
  for (int i = (0); i < (n); i++) cin >> x[i] >> y[i];
  vector<int> q;
  q.push_back(n - 1);
  for (int i = (n - 1) - 1; i >= (0); i--) {
    while (int((q).size()) > 1) {
      int u = q[int((q).size()) - 1];
      int v = q[int((q).size()) - 2];
      if (cross(x[v] - x[u], y[v] - y[u], x[i] - x[u], y[i] - y[u]) > 0) {
        q.pop_back();
      } else {
        break;
      }
    }
    nxt[i][0] = q.back();
    q.push_back(i);
  }
  nxt[n - 1][0] = n - 1;
  for (int k = (1); k < (maxe); k++)
    for (int i = (0); i < (n); i++) nxt[i][k] = nxt[nxt[i][k - 1]][k - 1];
  cin >> m;
  while (m--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    for (int i = (maxe)-1; i >= (0); i--) {
      if (!check(b, nxt[a][i])) {
        a = nxt[a][i];
      }
    }
    if (check(b, a)) {
      cout << a + 1 << " ";
    } else {
      cout << nxt[a][0] + 1 << " ";
    }
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
