#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int N = 1e6 + 6;
struct segt {
  vector<int> t;
  int d;
  segt(vector<int> &a) {
    int n = a.size();
    for (d = 2; d < n; d <<= 1)
      ;
    t.assign(d * 2, 0);
    for (int i = 0; i < n; ++i) t[i + d] = a[i];
    for (int i = d - 1; i; --i) t[i] = min(t[i * 2], t[i * 2 + 1]);
  }
  int rmq(int i, int j) {
    int res = 1e9;
    for (i += d, j += d; i <= j; ++i >>= 1, --j >>= 1) {
      if (i & 1) res = min(res, t[i]);
      if (~j & 1) res = min(res, t[j]);
    }
    return res;
  }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n;
  vector<pair<int, int>> s;
  set<int> u;
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    s.push_back({l, r});
    u.insert(l);
    u.insert(r);
    u.insert(r + 1);
  }
  vector<int> t((u).begin(), (u).end());
  vector<int> f(t.size());
  for (auto p : s) {
    int l = p.first;
    int r = p.second;
    f[lower_bound((t).begin(), (t).end(), l) - t.begin()]++;
    f[lower_bound((t).begin(), (t).end(), r + 1) - t.begin()]--;
  }
  for (int i = 1; i < f.size(); ++i) f[i] += f[i - 1];
  segt q(f);
  for (int k = 0; k < n; ++k) {
    int l = s[k].first;
    int r = s[k].second;
    int i = lower_bound((t).begin(), (t).end(), l) - t.begin();
    int j = lower_bound((t).begin(), (t).end(), r) - t.begin();
    if (q.rmq(i, j) != 1) {
      cout << k + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
