#include <bits/stdc++.h>
using namespace std;
vector<int> st;
bool Greater(pair<long long, long long> m1, pair<long long, long long> m2) {
  return (m1.first * m2.second - m1.second * m2.first) > 0;
}
long long y[100010], x[100010];
int Link[100010][20];
int level[100010];
int main() {
  int n, m, i, j;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%lld", &x[i]);
    scanf("%lld", &y[i]);
  }
  Link[n - 1][0] = n - 1;
  level[n - 1] = 0;
  st.push_back(n - 1);
  for (i = n - 2; i >= 0; --i) {
    while ((int)st.size() > 1) {
      int i1 = st[(int)st.size() - 1];
      int i2 = st[(int)st.size() - 2];
      if (Greater(make_pair(y[i2] - y[i1], x[i2] - x[i1]),
                  make_pair(y[i1] - y[i], x[i1] - x[i])))
        st.erase(st.end() - 1);
      else
        break;
    }
    Link[i][0] = st[(int)st.size() - 1];
    level[i] = 1 + level[Link[i][0]];
    st.push_back(i);
  }
  for (i = 1; i < 20; ++i)
    for (j = 0; j < n; ++j) Link[j][i] = Link[Link[j][i - 1]][i - 1];
  scanf("%d", &m);
  while (m--) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    --x;
    --y;
    if (level[x] < level[y]) swap(x, y);
    for (i = 20 - 1; i >= 0; --i)
      if (level[Link[x][i]] >= level[y]) x = Link[x][i];
    if (x == y) {
      printf("%d ", x + 1);
      continue;
    }
    for (i = 20 - 1; i >= 0; --i)
      if (Link[x][i] != Link[y][i]) {
        x = Link[x][i];
        y = Link[y][i];
      }
    printf("%d ", Link[x][0] + 1);
  }
}
