#include <bits/stdc++.h>
using namespace std;
int n, nb, l[400001], r[400001];
int sum, st[4000001], a[1000001], b[1000001];
map<int, int> used;
void up(int id, int l, int r, int i, int w) {
  if (i < l || i > r) return;
  if (l == r) {
    st[id] = w;
    return;
  }
  int mid = (l + r) / 2;
  up(id * 2, l, mid, i, w);
  up(id * 2 + 1, mid + 1, r, i, w);
  st[id] = min(st[id * 2], st[id * 2 + 1]);
}
int get(int id, int l, int r, int u, int v) {
  if (r < u || l > v) return INT_MAX;
  if (u <= l && r <= v) return st[id];
  int mid = (l + r) / 2;
  return min(get(id * 2, l, mid, u, v), get(id * 2 + 1, mid + 1, r, u, v));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &l[i], &r[i]);
    b[++nb] = l[i];
    b[++nb] = r[i];
    b[++nb] = r[i] + 1;
  }
  sort(b + 1, b + nb + 1);
  used[b[1]] = 1;
  for (int i = 2; i <= nb; i++)
    if (b[i] != b[i - 1]) used[b[i]] = used[b[i - 1]] + 1;
  for (int i = 1; i <= n; i++) {
    a[used[r[i] + 1]]--;
    l[i] = used[l[i]];
    r[i] = used[r[i]];
    a[l[i]]++;
  }
  nb = used[b[nb]];
  for (int i = 1; i <= nb; i++) {
    sum += a[i];
    up(1, 1, nb, i, sum);
  }
  for (int i = 1; i <= n; i++)
    if (get(1, 1, nb, l[i], r[i]) > 1) {
      cout << i;
      return 0;
    }
  cout << -1;
  return 0;
}
