#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 6e5 + 4;
int pre[N], arr[N], l[N], r[N];
map<int, int> m;
int main() {
  int n;
  scanf("%d", &n);
  int counter = 0;
  for (int i = 1; i < n + 1; i++) {
    scanf("%d", &l[i]);
    scanf("%d", &r[i]);
    m[r[i] + 1] = 0;
    m[l[i]] = 0;
    m[r[i]] = 0;
  }
  for (auto &it : m)
    if (it.second == 0) it.second = counter++;
  for (int i = 1; i < n + 1; i++) {
    l[i] = m[l[i]];
    r[i] = m[r[i]];
    arr[l[i]]++;
    arr[r[i] + 1]--;
  }
  for (int i = 1; i < N; i++) arr[i] += arr[i - 1];
  pre[0] = -1;
  for (int i = 0; i < N; i++) {
    if (arr[i] == 1)
      pre[i] = i;
    else if (i > 0)
      pre[i] = pre[i - 1];
  }
  for (int i = 1; i < n + 1; i++) {
    if (pre[r[i]] < l[i]) {
      printf("%d", i);
      return 0;
    }
  }
  printf("%d", -1);
  return 0;
}
