#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 1e5 + 2;
const int M = 5e6 + 2;
const int inf = 2e9;
const long long linf = 1e18;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int> > all;
  for (int i = 1; i <= n; i++) {
    int l, r;
    cin >> l >> r;
    all.push_back({l, i});
    all.push_back({r + 1, -i});
  }
  sort(all.begin(), all.end());
  vector<int> time(n + 1, 0);
  int prev = 0, cur = 0;
  set<int> intervals;
  for (int i = 0; i < all.size(); i++) {
    cur = all[i].first;
    int dif = cur - prev;
    prev = cur;
    if (intervals.size() == 1) {
      int what = *intervals.begin();
      time[what] += dif;
    }
    if (all[i].second > 0)
      intervals.insert(all[i].second);
    else
      intervals.erase(-all[i].second);
  }
  int idx = -1;
  for (int i = 1; i <= n; i++) {
    if (time[i] == 0) idx = i;
  }
  cout << idx << '\n';
  return 0;
}
