#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T qmin(const T &a, const T &b) {
  return a < b ? a : b;
}
template <typename T>
inline T qmax(const T &a, const T &b) {
  return a > b ? a : b;
}
template <typename T>
inline void getmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <typename T>
inline void getmax(T &a, const T &b) {
  if (a < b) a = b;
}
inline void fileio(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
const int inf = (int)1e9 + 7;
const long long linf = (long long)1e17 + 7;
const int N = 8e5 + 7, Node = N << 2;
int nums[N], sz;
int n, l[N], r[N];
int mn[Node], dt[Node];
inline void ins(int u, int l, int r, int l1, int r1) {
  if (l1 <= l && r <= r1) {
    ++dt[u], ++mn[u];
  } else {
    int mid = l + r >> 1;
    if (l1 <= mid) ins(((u) << 1), l, mid, l1, r1);
    if (r1 > mid) ins(((u) << 1 ^ 1), mid + 1, r, l1, r1);
    mn[u] = dt[u] + qmin(mn[((u) << 1)], mn[((u) << 1 ^ 1)]);
  }
}
inline int qry(int u, int l, int r, int l1, int r1) {
  if (l1 <= l && r <= r1) {
    return mn[u];
  } else {
    int ans = inf, mid = l + r >> 1;
    if (l1 <= mid) getmin(ans, dt[u] + qry(((u) << 1), l, mid, l1, r1));
    if (r1 > mid) getmin(ans, dt[u] + qry(((u) << 1 ^ 1), mid + 1, r, l1, r1));
    return ans;
  }
}
inline int id(int x) { return lower_bound(nums + 1, nums + sz + 1, x) - nums; }
int main() {
  scanf("%d", &n);
  for (register int i = (1); i <= (n); ++i) {
    scanf("%d%d", l + i, r + i);
    nums[++sz] = l[i];
    nums[++sz] = r[i];
    nums[++sz] = l[i] - 1;
    nums[++sz] = r[i] + 1;
  }
  sort(nums + 1, nums + sz + 1);
  sz = unique(nums + 1, nums + sz + 1) - nums - 1;
  for (register int i = (1); i <= (n); ++i) {
    l[i] = id(l[i]);
    r[i] = id(r[i]);
    ins(1, 1, sz, l[i], r[i]);
  }
  for (register int i = (1); i <= (n); ++i) {
    int v = qry(1, 1, sz, l[i], r[i]);
    if (v == 1) continue;
    printf("%d\n", i);
    return 0;
  }
  puts("-1");
  return 0;
}
