#include <bits/stdc++.h>
using namespace std;
template <class T>
struct rge {
  T b, e;
};
template <class T>
rge<T> range(T i, T j) {
  return rge<T>{i, j};
}
struct debug {
  template <class T>
  debug& operator<<(const T&) {
    return *this;
  }
};
using ll = long long;
template <typename T>
void min_self(T& a, T b) {
  a = min(a, b);
}
template <typename T>
void max_self(T& a, T b) {
  a = max(a, b);
}
const int mxN = 2500 * 1000 + 5;
int xs[mxN], N = 0;
const ll inf = 1e18;
class SegTree {
 public:
  struct Node {
    ll mn = inf;
    void merge(Node x, Node y) { mn = min(x.mn, y.mn); }
  };
  SegTree(int _n) : n(_n) {
    tree.resize(4 * n);
    lazy.resize(4 * n);
  }
  void build(int i, int L, int R) {
    if (L == R) {
      tree[i].mn = 0;
    } else {
      int m = L + (R - L) / 2;
      build(2 * i, L, m);
      build(2 * i + 1, m + 1, R);
      tree[i].merge(tree[2 * i], tree[2 * i + 1]);
    }
  }
  void push(int i) {
    ll& v = lazy[i];
    tree[2 * i].mn += v;
    lazy[2 * i] += v;
    tree[2 * i + 1].mn += v;
    lazy[2 * i + 1] += v;
    v = 0;
  }
  Node get(int i, int L, int R, int tl, int tr) {
    if (tl > tr) return Node();
    if (L == tl && tr == R) {
      return tree[i];
    } else {
      push(i);
      int m = L + (R - L) / 2;
      Node ans;
      ans.merge(get(2 * i, L, m, tl, min(tr, m)),
                get(2 * i + 1, m + 1, R, max(m + 1, tl), tr));
      return ans;
    }
  }
  ll get(int tl, int tr) {
    Node ans = get(1, 1, n, tl, tr);
    return ans.mn;
  }
  void upd(int i, int L, int R, int tl, int tr, int val) {
    if (tl > tr) return;
    if (L == tl && tr == R) {
      tree[i].mn += val;
      lazy[i] += val;
    } else {
      push(i);
      int m = L + (R - L) / 2;
      upd(2 * i, L, m, tl, min(tr, m), val);
      upd(2 * i + 1, m + 1, R, max(m + 1, tl), tr, val);
      tree[i].merge(tree[2 * i], tree[2 * i + 1]);
    }
  }
  void upd(int tl, int tr, int val) { upd(1, 1, n, tl, tr, val); }

 private:
  int n;
  vector<Node> tree;
  vector<ll> lazy;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> tv;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    for (int x : {a - 1, a, a + 1, b - 1, b, b + 1}) {
      xs[N++] = x;
    }
    tv.emplace_back(a, b);
  }
  sort(xs, xs + N);
  N = unique(xs, xs + N) - xs;
  SegTree st(N);
  st.build(1, 1, N);
  for (auto pp : tv) {
    int L = pp.first, R = pp.second;
    L = lower_bound(xs, xs + N, L) - xs;
    R = lower_bound(xs, xs + N, R) - xs;
    st.upd(L + 1, R + 1, 1);
  }
  int who = 1;
  for (auto pp : tv) {
    int L = pp.first, R = pp.second;
    L = lower_bound(xs, xs + N, L) - xs;
    R = lower_bound(xs, xs + N, R) - xs;
    if (st.get(L + 1, R + 1) > 1) {
      cout << who << "\n";
      exit(0);
    }
    who++;
  }
  cout << "-1\n";
}
