#include <bits/stdc++.h>
using namespace std;
int n;
const int MAXN = 8e5 + 228;
vector<pair<int, int> > a(MAXN);
map<int, int> q;
vector<int> as, qw;
vector<int> dp1(MAXN), dp2(MAXN);
long long t[4 * MAXN], lazy[4 * MAXN];
void build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v] = dp1[tl];
    lazy[v] = -1;
  } else {
    int tm = (tl + tr) >> 1;
    build(2 * v, tl, tm);
    build(2 * v + 1, tm + 1, tr);
    t[v] = min(t[2 * v], t[2 * v + 1]);
    lazy[v] = -1;
  }
}
long long get(int v, int tl, int tr, int l, int r) {
  if (l > r) {
    return 1e9 + 1;
  }
  if (tl == l && tr == r) {
    return t[v];
  }
  int tm = (tl + tr) >> 1;
  return min(get(2 * v, tl, tm, l, min(tm, r)),
             get(2 * v + 1, tm + 1, tr, max(tm + 1, l), r));
}
map<int, int> w;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    q[a[i].first]++;
    if (q[a[i].first] == 1) {
      qw.push_back(a[i].first);
    }
    q[a[i].second]++;
    if (q[a[i].second] == 1) {
      qw.push_back(a[i].second);
    }
  }
  sort(qw.begin(), qw.end());
  for (int i = 0; i < qw.size() - 1; i++) {
    as.push_back(qw[i]);
    if (qw[i + 1] - qw[i] > 1) {
      as.push_back(qw[i] + 1);
    }
  }
  as.push_back(qw.back());
  for (int i = 0; i < as.size(); i++) {
    w[as[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    int l = w[a[i].first], r = w[a[i].second];
    dp1[l]++;
    dp2[r]--;
  }
  int ans1 = 0;
  for (int i = 0; i < as.size(); i++) {
    ans1 += dp1[i];
    dp1[i] = ans1;
    ans1 += dp2[i];
  }
  build(1, 0, as.size() - 1);
  for (int i = 0; i < n; i++) {
    int az = get(1, 0, as.size() - 1, w[a[i].first], w[a[i].second]);
    if (az > 1) {
      cout << i + 1;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
