#include <bits/stdc++.h>
using namespace std;
struct st {
  int a, b, i, c;
};
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  vector<st> e;
  int a, b;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b;
    e.push_back({a, 0, i + 1, b});
    e.push_back({b + 1, 1, i + 1, a});
  }
  sort(e.begin(), e.end(), [](st &s1, st &s2) {
    if (s1.a == s2.a) {
      if (s1.b == s2.b) {
        if (s1.c == s2.c) {
          if (s1.b) return s1.i < s2.i;
          return s1.i > s2.i;
        }
        return s1.c > s2.c;
      }
      return s1.b < s2.b;
    }
    return s1.a < s2.a;
  });
  set<int> s, mk;
  for (auto i : e) {
    if (i.b == 0) {
      s.insert(i.i);
    } else {
      s.erase(s.find(i.i));
    }
    if (s.size() == 1) {
      mk.insert(*s.begin());
    }
  }
  for (int i = 1; i <= n; ++i)
    if (mk.find(i) == mk.end()) {
      cout << i;
      return 0;
    }
  cout << "-1";
  return 0;
}
