#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
const int INF = 1 << 30;
const int MOD = 1e9 + 7;
const int N = 4e5 + 10;
int c[N];
void add(int x, int y, int n) {
  for (; x <= n; x += x & -x) {
    c[x] += y;
  }
}
int query(int x) {
  int ret = 0;
  for (; x; x -= x & -x) {
    ret += c[x];
  }
  return ret;
}
int c2[N], val[N];
void add2(int x, int y, int n) {
  for (; x <= n; x += x & -x) {
    c2[x] = max(c2[x], y);
  }
}
int query2(int x, int y) {
  int ret = 0;
  for (int i = y; i >= x;) {
    int step = i & -i;
    if (i - step >= x - 1) {
      ret = max(ret, c2[i]);
      i -= step;
    } else {
      ret = max(ret, val[i]);
      --i;
    }
  }
  return ret;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > a(n);
  vector<int> A;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i].first, &a[i].second);
    ++a[i].second;
    A.push_back(a[i].first);
    A.push_back(a[i].second);
  }
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  for (int i = 0; i < n; ++i) {
    a[i].first = lower_bound(A.begin(), A.end(), a[i].first) - A.begin() + 1;
    a[i].second = lower_bound(A.begin(), A.end(), a[i].second) - A.begin() + 1;
    add(a[i].first, 1, A.size());
    add(a[i].second, -1, A.size());
  }
  for (int i = 0; i < A.size(); ++i) {
    val[i + 1] = n - query(i + 1);
    add2(i + 1, val[i + 1], A.size());
  }
  int ret = -1;
  for (int i = 0; i < n; ++i) {
    if (query2(a[i].first, a[i].second - 1) != n - 1) {
      ret = i + 1;
      break;
    }
  }
  printf("%d\n", ret);
  return 0;
}
