#include <bits/stdc++.h>
using namespace std;
const long double pi = acosl(-1);
const long double radian = 180 / pi;
const long double eps = 1e-12;
const int inf = 0x7f7f7f7f;
const long long infll = 0x7f7f7f7f7f7f7f7fll;
const long double infl = 1e20;
inline int sgn(const long double &x) { return (x > eps) - (x < -eps); }
inline int sgn(const long long &x) { return (x > 0) - (x < 0); }
inline long double sqr(const long double &x) { return x * x; }
inline long long sqr(const long long &x) { return x * x; }
inline long double refresh(const long double &x) {
  if (x < -1 + eps)
    return -1;
  else if (x > 1 - eps)
    return 1;
  else
    return x;
}
struct Point {
  long long x, y;
  Point() : x(0), y(0) {}
  Point(const long long &x, const long long &y) : x(x), y(y) {}
  long double length() const { return sqrtl(sqr(x) + sqr(y)); }
  long long length2() const { return sqr(x) + sqr(y); }
  long double distance(const Point &rhs) const {
    return (rhs - *this).length();
  }
  long long distance2(const Point &rhs) const {
    return (rhs - *this).length2();
  }
  Point conjugate() const { return Point(x, -y); }
  Point normal(const bool &lft = true) const {
    return lft ? Point(-y, x) : Point(y, -x);
  }
  Point moderate() const { return *this * (this->quadrant() <= 4 ? -1 : 1); }
  long long vect(const Point &lhs, const Point &rhs) const {
    return (lhs - *this) * (rhs - *this);
  }
  long long scal(const Point &lhs, const Point &rhs) const {
    return (lhs - *this) & (rhs - *this);
  }
  long double distance_to_line(const Point &p, const Point &q) const {
    return fabsl(p.vect(q, *this) / p.distance(q));
  }
  long double distance_to_segment(const Point &p, const Point &q) const {
    if (p.scal(q, *this) < 0)
      return p.distance(*this);
    else if (q.scal(p, *this) < 0)
      return q.distance(*this);
    else
      return this->distance_to_line(p, q);
  }
  bool on_line(const Point &p, const Point &q) const {
    return sgn(this->vect(p, q)) == 0;
  }
  bool on_halfline(const Point &p, const Point &q,
                   const bool &inclusive = true) const {
    if (*this == p)
      return inclusive;
    else
      return this->on_line(p, q) && sgn(p.scal(q, *this)) >= 0;
  }
  bool on_segment(const Point &p, const Point &q,
                  const bool &inclusive = true) const {
    if (*this == p || *this == q)
      return inclusive;
    else
      return this->on_line(p, q) && sgn(this->scal(p, q)) <= 0;
  }
  bool in_triangle(const Point &u, const Point &v, const Point &w,
                   const bool &inclusive = true) const {
    Point p[3] = {u, v, w};
    if (sgn(u.vect(v, w)) < 0) reverse(p, p + 3);
    for (int i = 0; i < 3; i++) {
      if (this->on_segment(p[i], p[(i + 1) % 3]))
        return inclusive;
      else if (sgn(this->vect(p[i], p[(i + 1) % 3])) < 0)
        return false;
    }
    return true;
  }
  bool in_angle(const Point &o, const Point &p, const Point &q,
                const bool &inclusive = true) const {
    if (this->on_halfline(o, p) || this->on_halfline(o, q)) return inclusive;
    int vp = sgn(o.vect(p, *this)), vq = sgn(o.vect(*this, q));
    if (sgn(o.vect(p, q)) >= 0)
      return vp > 0 && vq > 0;
    else
      return vp > 0 || vq > 0;
  }
  Point operator+(const Point &rhs) const {
    return Point(x + rhs.x, y + rhs.y);
  }
  Point operator-(const Point &rhs) const {
    return Point(x - rhs.x, y - rhs.y);
  }
  Point operator*(const long long &rhs) const {
    return Point(x * rhs, y * rhs);
  }
  Point operator/(const long long &rhs) const {
    return Point(x / rhs, y / rhs);
  }
  long long operator*(const Point &rhs) const { return x * rhs.y - y * rhs.x; }
  long long operator&(const Point &rhs) const { return x * rhs.x + y * rhs.y; }
  Point operator<<(const Point &rhs) const {
    return Point(x * rhs.x - y * rhs.y, x * rhs.y + y * rhs.x);
  }
  long double operator^(const Point &rhs) const {
    int s = sgn(*this * rhs);
    long double a = acosl(
        refresh((long double)(*this & rhs) / this->length() / rhs.length()));
    return s < 0 ? -a : a;
  }
  bool operator==(const Point &rhs) const { return x == rhs.x && y == rhs.y; }
  inline int quadrant() const {
    if (x == 0 && y == 0)
      return 0;
    else if (x < 0 && y < 0)
      return 1;
    else if (x == 0 && y < 0)
      return 2;
    else if (x > 0 && y < 0)
      return 3;
    else if (x > 0 && y == 0)
      return 4;
    else if (x > 0 && y > 0)
      return 5;
    else if (x == 0 && y > 0)
      return 6;
    else if (x < 0 && y > 0)
      return 7;
    else
      return 8;
  }
  bool operator<(const Point &rhs) const {
    int lq = quadrant(), rq = rhs.quadrant();
    if (lq != rq)
      return lq < rq;
    else {
      int s = sgn(*this * rhs);
      return s != 0 ? s > 0 : sgn(length2() - rhs.length2()) < 0;
    }
  }
  bool on_left(const Point &rhs, const bool &inclusive = true) const {
    long long s = *this * rhs, t = *this & rhs;
    return s == 0 ? t >= 0 || inclusive : s > 0;
  }
  bool on_right(const Point &rhs, const bool &inclusive = true) const {
    long long s = *this * rhs, t = *this & rhs;
    return s == 0 ? t >= 0 || inclusive : s < 0;
  }
};
inline bool xycmp(const Point &lhs, const Point &rhs) {
  if (lhs.x != rhs.x)
    return lhs.x < rhs.x;
  else
    return lhs.y < rhs.y;
}
inline bool yxcmp(const Point &lhs, const Point &rhs) {
  if (lhs.y != rhs.y)
    return lhs.y < rhs.y;
  else
    return lhs.x < rhs.x;
}
const int maxn = 100000;
struct LowestCommonAncestor {
  static const int maxn = ::maxn;
  static const int maxh = 17;
  int n;
  vector<int> E[maxn];
  int dph[maxn];
  int dad[maxn];
  int gpaf[maxn][maxh];
  LowestCommonAncestor() : n(0) {}
  LowestCommonAncestor(const int &n) : n(n) {}
  void resize(const int &n) {
    for (int i = 0; i < this->n; i++) E[i].clear();
    this->n = n;
  }
  void add_edge(const int &u, const int &v) { E[u].push_back(v); }
  void build(const int &root = 0) {
    memset(dph, 0x7f, sizeof dph[0] * n);
    dad[root] = -1;
    dph[root] = 0;
    queue<int> que;
    for (que.push(root); !que.empty(); que.pop()) {
      int u = que.front();
      for (const auto &v : E[u]) {
        if (dph[v] > dph[u] + 1) {
          dad[v] = u;
          dph[v] = dph[u] + 1;
          que.push(v);
        }
      }
    }
    for (int i = 0; i < n; i++) gpaf[i][0] = dad[i];
    for (int k = 1; k < maxh; k++) {
      for (int i = 0; i < n; i++) {
        gpaf[i][k] = dph[i] >= (1 << k) ? gpaf[gpaf[i][k - 1]][k - 1] : -1;
      }
    }
  }
  int gpa(int u, int h) const {
    for (int i = 0; h > 0; h >>= 1, i++) {
      if (h & 1) u = gpaf[u][i];
    }
    return u;
  }
  int lca(int u, int v) const {
    if (dph[u] > dph[v])
      u = gpa(u, dph[u] - dph[v]);
    else if (dph[u] < dph[v])
      v = gpa(v, dph[v] - dph[u]);
    if (u == v) return u;
    for (int k = maxh - 1; k >= 0; k--) {
      if (gpaf[u][k] != gpaf[v][k]) {
        u = gpaf[u][k];
        v = gpaf[v][k];
      }
    }
    return dad[u];
  }
  int distance(const int &u, const int &v) const {
    return dph[u] + dph[v] - dph[lca(u, v)] * 2;
  }
};
int n;
Point p[maxn];
int nxt[maxn];
int idx[maxn];
LowestCommonAncestor LCA;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> p[i].x >> p[i].y;
  int sz = 0;
  idx[sz++] = n - 1;
  nxt[n - 1] = n;
  for (int i = n - 2; i >= 0; i--) {
    for (; sz > 1 &&
           (p[idx[sz - 1]] - p[i]) * (p[idx[sz - 2]] - p[idx[sz - 1]]) > 0;
         sz--)
      ;
    nxt[i] = idx[sz - 1];
    idx[sz++] = i;
  }
  LCA.resize(n);
  for (int i = 0; i < n - 1; i++) {
    LCA.add_edge(i, nxt[i]);
    LCA.add_edge(nxt[i], i);
  }
  LCA.build(n - 1);
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    if (i > 0) cout << ' ';
    cout << LCA.lca(u, v) + 1 << endl;
  }
  return 0;
}
