#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, l, r, a, b;
  vector<pair<int, int>> t;
  bool p = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%d%*c%d", &a, &b);
    if (i == 0) {
      l = a;
      r = b;
    }
    if (a < l) l = a;
    if (b > r) r = b;
    t.push_back({a, b});
  }
  for (i = 0; i < n; i++) {
    if (t[i].first == l && t[i].second == r) {
      p = 1;
      break;
    }
  }
  p ? cout << ++i : cout << -1;
  return 0;
}
