#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 0, 1, -1, 1, 1, -1};
template <class T>
inline bool get(T& n) {
  char c, mul = 1;
  n = 0;
  while (!isdigit(c = getchar_unlocked()) && (c != EOF) && (c != '-'))
    ;
  if (c == EOF) return false;
  if (c == '-') {
    c = getchar_unlocked();
    mul = -1;
  }
  for (; isdigit(c); c = getchar_unlocked()) n = n * 10 + c - '0';
  n *= mul;
  return true;
}
inline void get(char& c) {
  while (isspace(c = getchar_unlocked()))
    ;
}
struct Point {
  long long x, y;
} p[101010];
long long cross(Point o, Point a, Point b) {
  return (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
}
int n;
int l[101010][20], par[101010], level[101010];
vector<int> child[101010];
void dfs(int u, int l) {
  level[u] = l;
  for (int(i) = 0, _ = (child[u].size()); (i) < _; ++i) dfs(child[u][i], l + 1);
}
void preprocess() {
  vector<int> v;
  int k = 0;
  for (int(i) = (n - 1), _ = (0); (i) >= _; --(i)) {
    par[i] = -1;
    while (k > 1 && cross(p[v[k - 2]], p[v[k - 1]], p[i]) < 0) {
      --k;
      v.pop_back();
    }
    if (k > 0) {
      par[i] = v.back();
      child[v.back()].push_back(i);
    }
    v.push_back(i);
    ++k;
  }
  int root = 0;
  while (par[root] != -1) root = par[root];
  dfs(root, 0);
  for (int(i) = 0, _ = (n); (i) < _; ++i)
    for (int j = 0; (1 << j) < n; ++j) l[i][j] = -1;
  for (int(i) = 0, _ = (n); (i) < _; ++i) l[i][0] = par[i];
  for (int j = 1; 1 << j < n; ++j)
    for (int(i) = 0, _ = (n); (i) < _; ++i)
      if (l[i][j - 1] != -1) l[i][j] = l[l[i][j - 1]][j - 1];
}
int lca(int p, int q) {
  int log, i;
  if (level[p] < level[q]) swap(p, q);
  for (log = 1; 1 << log <= level[p]; ++log)
    ;
  --log;
  for (i = log; i >= 0; --i)
    if (level[p] - (1 << i) >= level[q]) p = l[p][i];
  if (p == q) return p;
  for (i = log; i >= 0; --i)
    if (l[p][i] != -1 && l[p][i] != l[q][i]) p = l[p][i], q = l[q][i];
  return par[p];
}
int main() {
  get(n);
  for (int(i) = 0, _ = (n); (i) < _; ++i) get(p[i].x), get(p[i].y);
  preprocess();
  int m, a, b;
  get(m);
  while (m--) {
    get(a);
    get(b);
    --a;
    --b;
    printf("%d ", lca(a, b) + 1);
  }
  return 0;
}
