#include <bits/stdc++.h>
using namespace std;
const long long MOD = (1e9) + 7;
const long double EPS = 0.0000001;
const int N = 1200000 + 5000;
int tree[4 * N];
int lazy[4 * N];
inline void propagate(int node, int l, int r) {
  if (lazy[node] != 0) {
    tree[node] += (r - l + 1) * lazy[node];
    if (l != r) {
      lazy[2 * node] += lazy[node];
      lazy[2 * node + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
}
void update(int node, int l, int r, int a, int b, int val) {
  propagate(node, l, r);
  if (l > r || a > b || l > b || r < a) return;
  int mid = (l + r) / 2;
  int left = node + node;
  int right = left + 1;
  if (a <= l && r <= b) {
    tree[node] += (r - l + 1) * val;
    if (l != r) {
      lazy[left] += val;
      lazy[right] += val;
    }
    return;
  }
  update(left, l, mid, a, b, val);
  update(right, mid + 1, r, a, b, val);
  tree[node] = tree[2 * node] + tree[2 * node + 1];
}
int get(int node, int l, int r, int idx) {
  propagate(node, l, r);
  if (l > idx || r < idx) return 0;
  if (l == r) {
    return tree[node];
  }
  int mid = (l + r) / 2;
  int left = node + node;
  int right = left + 1;
  return get(left, l, mid, idx) + get(right, mid + 1, r, idx);
}
int tree2[4 * N];
void update2(int node, int l, int r, int idx, int val) {
  if (l > idx || r < idx) return;
  if (l == r) {
    tree2[node] = val;
    return;
  }
  int mid = (l + r) / 2;
  int left = node + node;
  int right = left + 1;
  update2(left, l, mid, idx, val);
  update2(right, mid + 1, r, idx, val);
  tree2[node] = min(tree2[left], tree2[right]);
}
int query(int node, int l, int r, int a, int b) {
  if (l > r || a > b || l > b || r < a) return INT_MAX;
  if (a <= l && r <= b) {
    return tree2[node];
  }
  int mid = (l + r) / 2;
  int left = node + node;
  int right = left + 1;
  return min(query(left, l, mid, a, b), query(right, mid + 1, r, a, b));
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  pair<int, int> queries[n];
  for (int i = 0; i < n; i++) cin >> queries[i].first >> queries[i].second;
  set<int> toHash;
  for (int i = 0; i < n; i++) {
    toHash.insert(queries[i].first);
    toHash.insert(queries[i].second);
    toHash.insert(queries[i].first - 1);
    toHash.insert(queries[i].second - 1);
    toHash.insert(queries[i].first + 1);
    toHash.insert(queries[i].second + 1);
  }
  map<int, int> compress;
  int cnt = 0;
  for (auto it : toHash) {
    compress[1 + it] = ++cnt;
  }
  for (int i = 0; i < n; i++) {
    int l = compress[1 + queries[i].first];
    int r = compress[1 + queries[i].second];
    update(1, 1, cnt, l, r, 1);
  }
  memset(tree2, INT_MIN, sizeof(tree2));
  for (int i = 1; i <= cnt; i++) {
    int x = get(1, 1, cnt, i);
    update2(1, 1, cnt, i, x);
  }
  int ans = -1;
  for (int i = 0; i < n; i++) {
    int l = compress[1 + queries[i].first];
    int r = compress[1 + queries[i].second];
    int x = query(1, 1, cnt, l, r);
    if (x > 1 && x != INT_MAX) {
      ans = i + 1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
