#include <bits/stdc++.h>
using namespace std;
struct node {
  vector<int> children;
  int parent, rank, ancestor;
  bool visited;
  vector<pair<int, int> > queries;
};
vector<node> V;
vector<int> answer;
void MakeSet(int x) {
  V[x].parent = x;
  V[x].rank = 0;
}
int Find(int x) {
  if (V[x].parent == x) return x;
  V[x].parent = Find(V[x].parent);
  return V[x].parent;
}
void Union(int x, int y) {
  int xRoot = Find(x);
  int yRoot = Find(y);
  if (V[xRoot].rank > V[yRoot].rank)
    V[yRoot].parent = xRoot;
  else if (V[xRoot].rank < V[yRoot].rank)
    V[xRoot].parent = yRoot;
  else if (xRoot != yRoot) {
    V[yRoot].parent = xRoot;
    V[xRoot].rank++;
  }
}
void TarjanOLCA(int u) {
  MakeSet(u);
  V[u].ancestor = u;
  for (vector<int>::iterator v = V[u].children.begin();
       v != V[u].children.end(); v++) {
    TarjanOLCA(*v);
    Union(u, *v);
    V[Find(u)].ancestor = u;
  }
  V[u].visited = true;
  for (vector<pair<int, int> >::iterator v = V[u].queries.begin();
       v != V[u].queries.end(); v++)
    if (V[v->first].visited) answer[v->second] = V[Find(v->first)].ancestor;
}
vector<int64_t> x, y;
vector<int> farthest;
int64_t ccw(int a, int b, int c) {
  return (x[b] - x[a]) * (y[c] - y[a]) - (y[b] - y[a]) * (x[c] - x[a]);
}
int main() {
  int n, m;
  cin >> n;
  V.resize(n);
  x.resize(n);
  y.resize(n);
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  vector<int> hull;
  do
    ;
  while (0);
  hull.push_back(n - 1);
  for (int i = n - 2; i >= 0; i--) {
    int a, b;
    for (;;) {
      a = hull[hull.size() - 1];
      if (hull.size() == 1) break;
      b = hull[hull.size() - 2];
      if (ccw(a, b, i) <= 0) break;
      hull.pop_back();
    }
    V[a].children.push_back(i);
    do
      ;
    while (0);
    hull.push_back(i);
  }
  cin >> m;
  answer.resize(m);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    V[a].queries.push_back(make_pair(b, i));
    V[b].queries.push_back(make_pair(a, i));
  }
  TarjanOLCA(n - 1);
  for (int i = 0; i < m; i++)
    printf("%d%s", answer[i] + 1, (i == m - 1 ? "\n" : " "));
  return 0;
}
