#include <bits/stdc++.h>
class H {
 public:
  H(long long int x, long long int y) : x(x), y(y), depth(), parents() {}
  long long int x;
  long long int y;
  long long int depth;
  std::vector<long long int> parents;
};
std::ostream &operator<<(std::ostream &out, const H &c) {
  out << "(" << c.x << ", " << c.y << ") nextVisible";
  for (auto p : c.parents) {
    out << "-> " << p;
  }
  out << "\n";
}
H operator-(H const &lhs, H const &rhs) {
  return H(lhs.x - rhs.x, lhs.y - rhs.y);
}
long long int cross(H const &a, H const &b, H const &c) {
  H one = b - a;
  H two = c - b;
  return one.x * two.y - two.x * one.y;
}
void buildTree(std::vector<H> &hills) {
  long long int i, j, k, bounce;
  std::vector<long long int> stk;
  for (i = hills.size() - 1; i >= 0; i--) {
    j = i + 1;
    if (j == hills.size()) {
      hills[i].depth = 0;
    } else if (j == hills.size() - 1) {
      hills[i].parents.emplace_back(stk.back());
      hills[i].depth = 1;
    } else {
      long long int iter = stk.size() - 1;
      while (i < hills.size() - 2 && iter - 1 >= 0 &&
             cross(hills[stk[iter - 1]], hills[stk[iter]], hills[i]) < 0) {
        assert(iter == stk.size() - 1);
        stk.pop_back();
        iter--;
      }
      bounce = 1;
      k = stk.size() - 1;
      hills[i].depth = hills[stk[k]].depth + 1;
      for (; k >= 0; k -= bounce, bounce <<= 1) {
        hills[i].parents.emplace_back(stk[k]);
      }
    }
    stk.push_back(i);
  }
}
long long int lca(std::vector<H> const &hills, long long int h, long long int l,
                  long long int log) {
  long long int diff, k;
  if (hills[h].depth < hills[l].depth) {
    std::swap(h, l);
  }
  diff = hills[h].depth - hills[l].depth;
  for (k = log; k >= 0; k--) {
    if (1 << k <= diff && (1 << k) & diff) {
      h = hills[h].parents[k];
    }
  }
  if (h == l) return h;
  for (k = log; k >= 0; k--) {
    if (1 << k <= hills[h].depth &&
        hills[h].parents[k] != hills[l].parents[k]) {
      h = hills[h].parents[k];
      l = hills[l].parents[k];
    }
  }
  return hills[h].parents[0];
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  long long int c, i, x, y, a, b, log;
  std::cin >> c;
  std::vector<H> hills;
  hills.reserve(c);
  log = 0;
  for (i = 1; i <= c; i <<= 1) log++;
  for (i = 1; i <= c; i++) {
    std::cin >> x >> y;
    hills.emplace_back(H(x, y));
  }
  buildTree(hills);
  std::ostringstream result;
  std::cin >> c;
  for (; c > 0; c--) {
    std::cin >> a >> b;
    result << lca(hills, a - 1, b - 1, log) + 1 << " ";
  }
  std::cout << result.str();
}
