#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b, long long int m) {
  long long int pp = (b == 0) ? 1 : power(a, b >> 1, m);
  pp = (pp * pp) % m;
  if (b & 1) pp = (pp * a) % m;
  return pp;
}
vector<long long int> vv;
long long int q[200005][3];
long long int pre[1000000] = {0};
unordered_map<long long int, long long int> m;
long long int tree[4000000];
void build(long long int nd, long long int st, long long int ed) {
  if (st == ed) {
    tree[nd] = pre[st];
    return;
  }
  long long int mid = (st + ed) >> 1;
  build(2 * nd, st, mid);
  build(2 * nd + 1, mid + 1, ed);
  tree[nd] = min(tree[2 * nd], tree[2 * nd + 1]);
}
long long int query(long long int nd, long long int st, long long int ed,
                    long long int l, long long int r) {
  if (st > ed || st > r || ed < l) return 1000000000000000;
  if (l <= st && ed <= r) return tree[nd];
  long long int mid = (st + ed) >> 1;
  return min(query(2 * nd, st, mid, l, r),
             query(2 * nd + 1, mid + 1, ed, l, r));
}
signed main() {
  long long int n;
  scanf("%lld", &(n));
  for (long long int i = 0; i < n; i++) {
    long long int u, v;
    scanf("%lld", &(u));
    scanf("%lld", &(v));
    vv.emplace_back(u);
    vv.emplace_back(v);
    q[i][1] = u;
    q[i][2] = v;
  }
  sort(vv.begin(), vv.end());
  vector<long long int>::iterator it = unique(vv.begin(), vv.end());
  vv.resize(distance(vv.begin(), it));
  long long int cnt = 0;
  for (long long int i = 0; i < vv.size(); i++) {
    m.insert(make_pair(vv[i], cnt++));
    if (i + 1 < vv.size() && vv[i + 1] != vv[i] + 1) cnt++;
  }
  for (long long int i = 0; i < n; i++) {
    pre[m[q[i][1]]]++;
    pre[m[q[i][2]] + 1]--;
  }
  for (long long int i = 1; i < 1000000; i++) pre[i] += pre[i - 1];
  build(1, 0, 1000000);
  long long int ans = -1;
  for (long long int i = 0; i < n; i++) {
    if (query(1, 0, 1000000, m[q[i][1]], m[q[i][2]]) >= 2) {
      ans = (i + 1);
      break;
    }
  }
  printf("%lld", (ans));
  return 0;
}
