#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
template <class T, class U>
using P = pair<T, U>;
using vll = V<ll>;
using vii = V<int>;
using vvll = V<vll>;
using vvii = V<V<int> >;
using PII = P<int, int>;
using PLL = P<ll, ll>;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class A, class B>
ostream& operator<<(ostream& out, const P<A, B>& p) {
  return out << '(' << p.first << ", " << p.second << ')';
}
template <class A>
ostream& operator<<(ostream& out, const V<A>& v) {
  out << '[';
  for (int i = 0; i < int(v.size()); i++) {
    if (i) out << ", ";
    out << v[i];
  }
  return out << ']';
}
const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;
template <typename T>
class SegmentTree {
  int n;
  std::vector<T> data;
  T def;
  std::function<T(T, T)> operation, update;

 public:
  SegmentTree(size_t _n, T _def, std::function<T(T, T)> _ope,
              std::function<T(T, T)> _upd)
      : n(_n), def(_def), operation(_ope), update(_upd) {
    n = 1;
    while (n < _n) n <<= 1;
    data = std::vector<T>(2 * n - 1, def);
  }
  void build(std::vector<T> td) {
    for (int i = 0; i < int(td.size()); i++) data[i + n - 1] = td[i];
    for (int i = n - 2; i >= 0; i--)
      data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
  }
  void change(int i, T x) {
    i += n - 1;
    data[i] = update(data[i], x);
    while (i > 0) {
      i = (i - 1) >> 1;
      data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }
  T query(int l, int r) {
    assert(l < r);
    T ret = def;
    l += n - 1, r += n - 1;
    while (l < r) {
      if (!(l & 1)) ret = operation(data[l], ret);
      if (!(r & 1)) ret = operation(data[r - 1], ret);
      l >>= 1;
      r = (r - 1) >> 1;
    }
    return ret;
  }
  T operator[](int i) { return data[i + n - 1]; }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vii comp;
  V<PII> lr(n);
  for (ll i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    lr[i] = PII(l, r);
    comp.emplace_back(l), comp.emplace_back(r);
  }
  sort(comp.begin(), comp.end());
  comp.erase(unique(comp.begin(), comp.end()), comp.end());
  vii imos(int(comp.size()), 0);
  V<PII> lri(n);
  for (ll i = 0; i < n; i++) {
    int li = lower_bound(comp.begin(), comp.end(), lr[i].first) - comp.begin(),
        ri = lower_bound(comp.begin(), comp.end(), lr[i].second) - comp.begin();
    lri[i] = PII(li, ri);
    imos[li]++, imos[ri]--;
  }
  for (ll i = 1; i < int(imos.size()); i++) imos[i] += imos[i - 1];
  SegmentTree<int> seg(
      int(imos.size()), INF, [&](int i, int j) { return min(i, j); },
      [&](int i, int j) { return j; });
  seg.build(imos);
  int ans = -1;
  for (ll i = 0; i < n; i++) {
    if (seg.query(lri[i].first, lri[i].second) > 1) {
      ans = i + 1;
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}
