#include <bits/stdc++.h>
using namespace std;
struct Tree {
  vector<int> vals, mx;
  int siz;
  void init(int n) {
    siz = 1;
    while (siz < n) siz <<= 1;
    vals.resize(2 * siz, 0);
    mx.resize(2 * siz, 0);
  }
  void add(int a, int b, int v) {
    int l = siz + a, r = siz + b;
    vals[l] += v;
    mx[l] += v;
    if (r != l) {
      vals[r] += v;
      mx[r] += v;
    }
    while (l > 1) {
      if (l < r - 1) {
        if (l % 2 == 0) {
          vals[l + 1] += v;
          mx[l + 1] += v;
        }
        if (r % 2 == 1) {
          vals[r - 1] += v;
          mx[r - 1] += v;
        }
      }
      l /= 2;
      r /= 2;
      mx[l] = min(mx[l + l], mx[l + l + 1]) + vals[l];
      mx[r] = min(mx[r + r], mx[r + r + 1]) + vals[r];
    }
  }
  int query(int a, int b) {
    int l = siz + a, r = siz + b;
    int ret = 0, lm = vals[l], rm = vals[r];
    while (l != r) {
      if (l != r - 1) {
        if (l % 2 == 0) lm = min(lm, mx[l + 1]);
        if (r % 2 == 1) rm = min(rm, mx[r - 1]);
      }
      l /= 2;
      r /= 2;
      lm += vals[l];
      rm += vals[r];
    }
    ret = min(lm, rm);
    while (l > 1) {
      l /= 2;
      ret += vals[l];
    }
    return ret;
  }
};
pair<int, int> tab[200005];
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  unordered_set<int> coords;
  for (int(i) = 0; (i) < (n); ++(i)) {
    cin >> tab[i].first >> tab[i].second;
    coords.insert(tab[i].first);
    coords.insert(tab[i].second);
  }
  vector<int> sorted;
  for (int c : coords) sorted.push_back(c);
  sort((sorted).begin(), (sorted).end());
  unordered_map<int, int> remap;
  int lastC = -1, lastR = -1;
  for (int(i) = 0; (i) < (sorted.size()); ++(i)) {
    if (sorted[i] == lastC + 1) {
      remap[sorted[i]] = lastR + 1;
      lastR += 1;
    } else {
      remap[sorted[i]] = lastR + 2;
      lastR += 2;
    }
    lastC = sorted[i];
  }
  Tree tree;
  tree.init(lastR + 1);
  for (int(i) = 0; (i) < (n); ++(i))
    tree.add(remap[tab[i].first], remap[tab[i].second], 1);
  for (int(i) = 0; (i) < (n); ++(i)) {
    if (tree.query(remap[tab[i].first], remap[tab[i].second]) > 1) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}
