#include <bits/stdc++.h>
using namespace std;
long long n, l, r;
vector<long long> a(800005), seg(4 * 800005);
void build(long long cur, long long st, long long end) {
  if (st == end) {
    seg[cur] = a[st];
    return;
  }
  long long mid = (st + end) >> 1;
  build(2 * cur, st, mid);
  build(2 * cur + 1, mid + 1, end);
  seg[cur] = min(seg[2 * cur], seg[2 * cur + 1]);
}
long long query(long long cur, long long st, long long end, long long l,
                long long r) {
  if (l <= st && r >= end) return seg[cur];
  if (r < st || l > end) return 10000000000007LL;
  long long mid = (st + end) >> 1;
  long long ans1 = query(2 * cur, st, mid, l, r);
  long long ans2 = query(2 * cur + 1, mid + 1, end, l, r);
  return min(ans1, ans2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, i, j, x, y;
  cin >> n;
  set<long long> s;
  vector<pair<long long, long long> > aa;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    s.insert(x);
    s.insert(x - 1);
    s.insert(y);
    s.insert(y + 1);
    aa.push_back(make_pair(x, y));
  }
  long long cnt = 1;
  map<long long, long long> m;
  for (auto i : s) m[i] = cnt++;
  for (i = 0; i < n; i++) {
    aa[i].first = m[aa[i].first];
    aa[i].second = m[aa[i].second];
  }
  for (i = 0; i < n; i++) {
    a[aa[i].first] += 1;
    a[aa[i].second + 1] -= 1;
  }
  for (i = 1; i <= 800004; i++) a[i] += a[i - 1];
  build(1, 1, 800003);
  for (i = 0; i < n; i++) {
    if (query(1, 1, 800004, aa[i].first, aa[i].second) > 1) {
      cout << i + 1;
      return 0;
    }
  }
  cout << "-1";
  return 0;
}
