#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 5, mod = 1e9 + 7, inf = 1e9 + 7;
const ll INF = 1e18 + 5;
set<pair<int, int> > st;
map<pair<int, int>, int> mp;
int l[N], r[N];
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> l[i] >> r[i];
    mp[{l[i], r[i]}] = i;
  }
  for (int i = 1; i <= n; ++i) {
    if (st.empty()) {
      st.insert({l[i], r[i]});
      continue;
    } else {
      auto it = st.lower_bound({l[i], 0});
      while (it != st.end() && r[i] >= it->second) {
        cout << mp[{it->first, it->second}];
        return 0;
      }
      if (it != st.begin()) {
        it--;
        auto it2 = it;
        if (it2 != st.begin()) {
          it2--;
          if (it2->second >= l[i] - 1 && it->second < r[i]) {
            cout << mp[*it];
            return 0;
          }
        }
        if (it->second >= r[i]) {
          cout << i;
          return 0;
        }
        int daun = it->second;
        ++it;
        if (it != st.end()) {
          if (daun >= it->first - 1) {
            cout << i;
            return 0;
          }
        }
      }
      st.insert({l[i], r[i]});
    }
  }
  st.clear();
  for (int i = n; i >= 1; i--) {
    if (st.empty()) {
      st.insert({l[i], r[i]});
      continue;
    } else {
      auto it = st.lower_bound({l[i], 0});
      while (it != st.end() && r[i] >= it->second) {
        cout << mp[{it->first, it->second}];
        return 0;
      }
      if (it != st.begin()) {
        it--;
        auto it2 = it;
        if (it2 != st.begin()) {
          it2--;
          if (it2->second >= l[i] - 1 && it->second < r[i]) {
            cout << mp[*it];
            return 0;
          }
        }
        if (it->second >= r[i]) {
          cout << i;
          return 0;
        }
        int daun = it->second;
        ++it;
        if (it != st.end()) {
          if (daun >= it->first - 1) {
            cout << i;
            return 0;
          }
        }
      }
      st.insert({l[i], r[i]});
    }
  }
  cout << -1;
  return 0;
}
