#include <bits/stdc++.h>
using namespace std;
long long tree[4 * 1000000];
long long lazy[4 * 1000000];
void propagate(int node, int b, int e) {
  int value = lazy[node];
  tree[node] += value;
  if (b != e) {
    int L = 2 * node;
    int R = L + 1;
    lazy[L] += value;
    lazy[R] += value;
  }
  lazy[node] = 0;
}
void update(int node, int b, int e, int i, int j, int x) {
  if (lazy[node]) propagate(node, b, e);
  if (b >= i && e <= j) {
    lazy[node] = x;
    propagate(node, b, e);
    return;
  }
  if (b > j || e < i) return;
  int mid = (b + e) / 2;
  int L = 2 * node;
  int R = L + 1;
  update(L, b, mid, i, j, x);
  update(R, mid + 1, e, i, j, x);
  tree[node] = min(tree[L], tree[R]);
}
int query(int node, int b, int e, int i, int j) {
  if (lazy[node]) propagate(node, b, e);
  if (b > j || e < i) return 1000000000;
  if (b >= i && e <= j) {
    return tree[node];
  }
  int L = 2 * node;
  int R = L + 1;
  int mid = (b + e) / 2;
  int p = query(L, b, mid, i, j);
  int q = query(R, mid + 1, e, i, j);
  return min(p, q);
}
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > v;
  map<int, int> mp;
  vector<int> loc;
  int k = 0;
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    v.push_back({x, y});
    if (!mp[x]) loc.push_back(x);
    if (!mp[y]) loc.push_back(y);
    if (!mp[x - 1]) loc.push_back(x - 1);
    mp[x] = mp[x - 1] = mp[y] = 1;
  }
  sort(loc.begin(), loc.end());
  for (auto i : loc) mp[i] = ++k;
  for (auto i : v) {
    int x = i.first, y = i.second;
    update(1, 1, k, mp[x], mp[y], 1);
  }
  for (int i = 0; i < v.size(); i++) {
    int x = v[i].first, y = v[i].second;
    int ans = query(1, 1, k, mp[x], mp[y]);
    if (ans > 1) {
      printf("%d\n", i + 1);
      return 0;
    }
  }
  puts("-1");
  return 0;
}
