#include <bits/stdc++.h>   using namespace std;   const long long N = 100100, mod = 1e9 + 7, mod2 = 1e9 + 9, mod3 = 998244353,                   sq = 450, base = 727, lg = 30;   long long n, m, x, y, z, w, ans, t, l[N], r[N];   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> l[i] >> r[i];       if (i == 0) {         x = l[i];         y = r[i];         continue;       }       x = min(x, l[i]);       y = max(y, r[i]);     }     for (int i = 0; i < n; i++) {       if (l[i] == x && r[i] == y) return cout << i + 1, 0;     }     cout << -1;     return 0;   }   