#include <bits/stdc++.h>
using namespace std;
long long n, a[200009][2], b[800009], z, f[800090], j;
map<long long, long long> mp;
long long k, tr[400009 * 8], x, y;
void build(long long d, long long l, long long r) {
  if (l == r)
    tr[d] = f[l];
  else {
    int m = (l + r) / 2;
    build(d * 2, l, m);
    build(d * 2 + 1, m + 1, r);
    tr[d] = min(tr[d * 2], tr[d * 2 + 1]);
  }
}
long long q(long long d, long long l, long long r, long long f, long long t) {
  if (f > r || t < l) return 1e9 + 7;
  if (r <= t && l >= f) return tr[d];
  int m = (l + r) / 2;
  int A = q(d * 2, l, m, f, t);
  int B = q(d * 2 + 1, m + 1, r, f, t);
  return min(A, B);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i][0] >> a[i][1];
    b[j++] = a[i][0];
    b[j++] = a[i][1];
    b[j++] = a[i][1] + 1;
    b[j++] = a[i][0] - 1;
  }
  sort(b, b + j);
  for (int i = 0; i < j; i++)
    if (mp[b[i]] == 0) mp[b[i]] = ++z;
  for (int i = 0; i < n; i++) {
    f[mp[a[i][0]]]++;
    f[mp[a[i][1]] + 1]--;
  }
  for (int i = 1; i <= z + 3; i++) f[i] += f[i - 1];
  build(1, 1, z);
  for (int i = 0; i < n; i++) {
    if (q(1, 1, z, mp[a[i][0]], mp[a[i][1]]) > 1) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << -1;
}
