#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
template <class T>
struct SegTree {
  int n, N;
  vector<T> tree, lazy;
  const T ID = 0;
  SegTree(int _n) {
    n = _n, N = 4 * _n;
    tree.assign(N, ID), lazy.assign(N, ID);
  }
  T comb(T a, T b) { return min(a, b); }
  void prop(int i, int st, int en) {
    tree[i] += lazy[i];
    if (st != en) {
      lazy[2 * i] += lazy[i];
      lazy[2 * i + 1] += lazy[i];
    }
    lazy[i] = ID;
  }
  void _update(int i, int st, int en, int l, int r, T val) {
    if (lazy[i] != ID) prop(i, st, en);
    if (en < l || st > r) return;
    if (l <= st && en <= r) {
      lazy[i] = val;
      prop(i, st, en);
      return;
    }
    int mid = (st + en) / 2;
    _update(2 * i, st, mid, l, r, val);
    _update(2 * i + 1, mid + 1, en, l, r, val);
    tree[i] = comb(tree[2 * i], tree[2 * i + 1]);
  }
  T _query(int i, int st, int en, int l, int r) {
    if (lazy[i] != ID) prop(i, st, en);
    if (en < l || st > r) return LLONG_MAX;
    if (l <= st && en <= r) return tree[i];
    int mid = (st + en) / 2;
    return comb(_query(2 * i, st, mid, l, r),
                _query(2 * i + 1, mid + 1, en, l, r));
  }
  T query(int l, int r) { return _query(1, 1, n, l, r); }
  void update(int l, int r, T val) { _update(1, 1, n, l, r, val); }
};
void solve() {
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  vector<int> temp;
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
    temp.push_back(v[i].first);
    temp.push_back(v[i].second);
  }
  sort(temp.begin(), temp.end());
  int k = 0, last = -1;
  for (int i = 0; i < ((int)(temp).size()); i++) {
    if (temp[i] != last) {
      last = temp[i];
      temp[k++] = temp[i];
    }
  }
  temp.erase(temp.begin() + k, temp.end());
  vector<int> temp2;
  for (int i = 0; i < ((int)(temp).size()); i++) {
    temp2.push_back(temp[i]);
    if (i < ((int)(temp).size()) - 1 and temp[i + 1] > temp[i] + 1)
      temp2.push_back(temp[i] + 1);
  }
  temp = temp2;
  SegTree<long long> S(((int)(temp).size()));
  for (int i = 0; i < n; i++) {
    int x = lower_bound(temp.begin(), temp.end(), v[i].first) - temp.begin(),
        y = lower_bound(temp.begin(), temp.end(), v[i].second) - temp.begin();
    x++;
    y++;
    S.update(x, y, 1);
  }
  for (int i = 0; i < n; i++) {
    int x = lower_bound(temp.begin(), temp.end(), v[i].first) - temp.begin(),
        y = lower_bound(temp.begin(), temp.end(), v[i].second) - temp.begin();
    x++;
    y++;
    if (S.query(x, y) > 1) {
      cout << i + 1;
      return;
    }
  }
  cout << -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
}
