#include <bits/stdc++.h>
using namespace std;
int mp[400000];
pair<int, int> tv[200000];
vector<pair<bool, int> > ev[400000];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (int)n; ++i) {
    scanf("%d%d", &tv[i].first, &tv[i].second);
    ++tv[i].second;
    mp[i << 1] = tv[i].first;
    mp[i << 1 | 1] = tv[i].second;
  }
  sort(mp, mp + (n << 1));
  for (int i = 0; i < (int)n; ++i) {
    tv[i].first = lower_bound(mp, mp + (n << 1), tv[i].first) - mp;
    tv[i].second = lower_bound(mp, mp + (n << 1), tv[i].second) - mp;
    ev[tv[i].first].push_back(make_pair(false, i + 1));
    ev[tv[i].second].push_back(make_pair(true, i + 1));
  }
  set<int> an;
  int fr = 0;
  for (int i = 0; i < (int)n << 1; ++i) {
    sort(ev[i].begin(), ev[i].end());
    for (int j = 0; j < (int)ev[i].size(); ++j) {
      int id = ev[i][j].second;
      if (ev[i][j].first) {
        if (an.find(id) != an.end()) {
          printf("%d\n", id);
          return 0;
        }
        --fr;
      } else {
        ++fr;
        an.insert(id);
      }
    }
    if (fr < 2) an.clear();
  }
  printf("-1\n");
}
