#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int lazy[16 * N], tree[16 * N], x[N], y[N], ind[N][2], n, k, bef, cur;
vector<pair<int, pair<int, int> > > v;
void update(int u, int start, int end, int l, int r) {
  if (lazy[u]) {
    tree[u] += lazy[u];
    if (l != r) {
      lazy[2 * u] += lazy[u];
      lazy[2 * u + 1] += lazy[u];
    }
    lazy[u] = 0;
  }
  if (l > end || r < start) return;
  if (start <= l && r <= end) {
    tree[u]++;
    if (l != r) {
      lazy[2 * u]++;
      lazy[2 * u + 1]++;
    }
    return;
  }
  int mid = (l + r) / 2;
  update(2 * u, start, end, l, mid);
  update(2 * u + 1, start, end, mid + 1, r);
  tree[u] = min(tree[2 * u + 1], tree[2 * u]);
}
int getans(int u, int start, int end, int l, int r) {
  if (lazy[u]) {
    tree[u] += lazy[u];
    if (l != r) {
      lazy[2 * u] += lazy[u];
      lazy[2 * u + 1] += lazy[u];
    }
    lazy[u] = 0;
  }
  if (l > end || r < start) return 1e6;
  if (start <= l && r <= end) {
    return tree[u];
  }
  int mid = (l + r) / 2;
  return min(getans(2 * u, start, end, l, mid),
             getans(2 * u + 1, start, end, mid + 1, r));
}
int main() {
  cin >> n;
  for (k = 1; k <= n; k++) {
    cin >> x[k] >> y[k];
    v.push_back({x[k], {k, 0}});
    v.push_back({y[k], {k, 1}});
  }
  bef = -1;
  sort(v.begin(), v.end());
  for (k = 0; k < v.size(); k++) {
    if (bef != v[k].first) {
      if (bef + 1 < v[k].first) cur++;
      bef = v[k].first;
      cur++;
    }
    ind[v[k].second.first][v[k].second.second] = cur;
  }
  for (k = 1; k <= n; k++) {
    update(1, ind[k][0], ind[k][1], 1, cur);
  }
  for (k = 1; k <= n; k++) {
    if (getans(1, ind[k][0], ind[k][1], 1, cur) >= 2) {
      cout << k;
      return 0;
    }
  }
  cout << -1;
}
