#include <bits/stdc++.h>
using namespace std;
long long z = 1e9 + 7;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % z;
      b--;
    }
    a = (a * a) % z;
    b = b >> 1;
  }
  return res;
}
vector<long long> sieve;
vector<long long> seg;
void arrange(long long i, long long v, long long x, long long lx,
             long long rx) {
  if (rx - lx == 1) {
    seg[x] = v;
    return;
  }
  long long m = (lx + rx) / 2;
  if (i < m)
    arrange(i, v, 2 * x + 1, lx, m);
  else
    arrange(i, v, 2 * x + 2, m, rx);
  seg[x] = min(seg[2 * x + 1], seg[2 * x + 2]);
}
long long calc(long long l, long long r, long long x, long long lx,
               long long rx) {
  if (l >= rx || r <= lx) return 1e9;
  if (lx >= l && rx <= r) return seg[x];
  long long mid = (lx + rx) / 2;
  long long sl = calc(l, r, 2 * x + 1, lx, mid),
            sr = calc(l, r, 2 * x + 2, mid, rx);
  return min(sl, sr);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<long long> pp;
  pp.assign(1000001, 0);
  for (long long i = 2; i < 1000; i++) {
    if (!pp[i]) {
      for (long long j = i * i; j <= 1000000; j += i) {
        pp[j] = 1;
      }
    }
  }
  for (long long i = 2; i <= 1000000; i++)
    if (!pp[i]) sieve.push_back(i);
  long long t;
  t = 1;
  while (t--) {
    long long n, l, r;
    cin >> n;
    map<long long, long long> m;
    vector<pair<long long, long long> > v;
    for (long long i = 0; i < n; i++) {
      cin >> l >> r;
      v.push_back(make_pair(l, r));
      m[l]++;
      m[r + 1]--;
    }
    map<long long, long long>::iterator iterator = m.begin();
    long long k = iterator->first;
    for (; iterator != m.end(); iterator++) {
      if (iterator == m.begin()) continue;
      m[iterator->first] += m[k];
      k = iterator->first;
    }
    long long p = 0;
    map<long long, long long> m1;
    for (iterator = m.begin(); iterator != m.end(); iterator++) {
      m1[iterator->first] = p;
      p++;
    }
    long long s = 1;
    while (s < p) s *= 2;
    seg.assign(2 * s, 0);
    for (iterator = m.begin(); iterator != m.end(); iterator++) {
      arrange(m1[iterator->first], iterator->second, 0, 0, s);
    }
    long long ans = -1;
    for (long long i = 0; i < n; i++) {
      l = v[i].first, r = v[i].second;
      l = m1[l], r = m1[r + 1];
      if (calc(l, r, 0, 0, s) >= 2) {
        ans = i + 1;
        break;
      }
    }
    cout << ans << "\n";
  }
}
