#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
struct node {
  node *l, *p;
  int val;
  int spa;
  node() {
    val = 0;
    spa = 0;
    l = p = nullptr;
  }
  node* lew() {
    if (l == nullptr) l = new node();
    return l;
  }
  node* pra() {
    if (p == nullptr) p = new node();
    return p;
  }
  void touch() {
    val += spa;
    lew()->spa += spa;
    pra()->spa += spa;
    spa = 0;
  }
  void dodaj(int p, int k, int a, int b) {
    if (a <= p && k <= b) {
      spa++;
      return;
    }
    if (p >= b || k <= a) return;
    touch();
    int s = (p + k) / 2;
    lew()->dodaj(p, s, a, b);
    pra()->dodaj(s, k, a, b);
    lew()->touch();
    pra()->touch();
    val = min(lew()->val, pra()->val);
  }
  int czytaj(int p, int k, int a, int b) {
    touch();
    if (a <= p && k <= b) {
      return val;
    }
    if (p >= b || k <= a) return 2;
    int s = (p + k) / 2;
    return min(lew()->czytaj(p, s, a, b), pra()->czytaj(s, k, a, b));
  }
};
node* root;
int main() {
  int n;
  root = new node();
  scanf("%d", &n);
  vector<pair<int, int>> q;
  vector<int> ska;
  for (int i = 0; i < n; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    q.push_back({l, r});
    ska.push_back(l);
    ska.push_back(r + 1);
  }
  sort(ska.begin(), ska.end());
  ska.resize(unique(ska.begin(), ska.end()) - ska.begin());
  map<int, int> skalowanie;
  for (int i = 0; i < ska.size(); i++) {
    skalowanie[ska[i]] = i;
  }
  int n2 = 1;
  while (n2 <= ska.size()) n2 *= 2;
  for (auto p : q) {
    root->dodaj(0, n2, skalowanie[p.first], skalowanie[p.second + 1]);
  }
  for (int i = 0; i < n; i++) {
    auto p = q[i];
    if (root->czytaj(0, n2, skalowanie[p.first], skalowanie[p.second + 1]) >
        1) {
      printf("%d\n", i + 1);
      return 0;
    }
  }
  printf("-1\n");
}
