#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
void tracer(istream_iterator<string> it) {}
template <typename T, typename... Args>
void tracer(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << " | ";
  tracer(++it, args...);
}
const int INF = 2e9;
const long long LINF = 2e18;
const long long MOD = 1e9 + 7;
const double err = 1e-10;
const int N = 6e5 + 5;
const int K = 21;
map<int, int> mp;
vector<int> util(N, 0);
int st[N][K + 1];
int log_2[N];
void sparse_build() {
  for (int j = 1; j <= K; j++) {
    for (int i = 0; i + (1 << j) < N; i++) {
      st[i][j] = min(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]);
    }
  }
  log_2[1] = 0;
  for (int i = 2; i < N; i++) {
    log_2[i] = log_2[i / 2] + 1;
  }
}
int answer_query(int l, int r) {
  int j = log_2[r - l + 1];
  int minimum = min(st[l][j], st[r - (1 << j) + 1][j]);
  return minimum;
}
void solve() {
  int n;
  cin >> n;
  int ls[n], rs[n];
  for (int i = 0; i < n; i++) {
    cin >> ls[i];
    cin >> rs[i];
    mp[ls[i]];
    mp[rs[i]];
    mp[rs[i] + 1];
  }
  int idx = 0;
  for (auto x : mp) {
    mp[x.first] = idx++;
  }
  for (int i = 0; i < n; i++) {
    ls[i] = mp[ls[i]];
    rs[i] = mp[rs[i]];
    util[ls[i]]++;
    util[rs[i] + 1]--;
  }
  for (int i = 0; i < N; i++) {
    util[i] += (i - 1 >= 0 ? util[i - 1] : 0);
    st[i][0] = util[i];
  }
  sparse_build();
  for (int i = 0; i < n; i++) {
    if (answer_query(ls[i], rs[i]) > 1) {
      cout << i + 1 << "\n";
      return;
    }
  }
  cout << "-1\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T = 1;
  for (int i = 1; i <= T; i++) {
    solve();
  }
  return 0;
}
