#include <bits/stdc++.h>
using namespace std;
int mpow(int base, int exp);
const int mod = 1000000007;
const int N = 3e5, M = N;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (int i = 0; i < v.size(); ++i) {
    if (i) os << ", ";
    os << v[i];
  }
  os << "]\n";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  os << "{";
  for (auto it : v) {
    os << it;
    if (it != *v.rbegin()) os << ", ";
  }
  os << "}\n";
  return os;
}
template <typename T, typename second>
ostream& operator<<(ostream& os, const map<T, second>& v) {
  os << "{";
  for (auto it : v) {
    os << "(" << it.first << " : " << it.second << ")";
    if (it != *v.rbegin()) os << ", ";
  }
  os << "}\n";
  return os;
}
template <typename T, typename second>
ostream& operator<<(ostream& os, const pair<T, second>& v) {
  os << "(";
  os << v.first << ", " << v.second << ")";
  return os;
}
template <typename T>
inline istream& operator>>(istream& in, vector<T>& a) {
  for (auto& x : a) in >> x;
  return in;
}
template <int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
  static_assert(D >= 1, "Vector dimension must be greater than zero!");
  template <typename... Args>
  Vec(int n = 0, Args... args)
      : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {}
};
template <typename T>
struct Vec<1, T> : public vector<T> {
  Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}
};
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char* x) { cerr << '\"' << x << '\"'; }
void __print(const string& x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V>& x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T& x) {
  int f = 0;
  cerr << '{';
  for (auto& i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
vector<pair<int, int>> tv;
map<int, int> m;
template <int sz>
struct LazySegTree {
  int mn[2 * sz], lazy[2 * sz];
  LazySegTree() {
    memset(mn, 0, sizeof mn);
    memset(lazy, 0, sizeof lazy);
  }
  void push(int ind, int L, int R) {
    mn[ind] += lazy[ind];
    if (L != R) lazy[2 * ind] += lazy[ind], lazy[2 * ind + 1] += lazy[ind];
    lazy[ind] = 0;
  }
  void pull(int ind) { mn[ind] = min(mn[2 * ind], mn[2 * ind + 1]); }
  void build() {
    for (int i = sz - 1; i > 0; --i) pull(i);
  }
  int qmin(int lo, int hi, int ind = 1, int L = 0, int R = sz - 1) {
    push(ind, L, R);
    if (lo > R || L > hi) return mod;
    if (lo <= L && R <= hi) return mn[ind];
    int M = (L + R) / 2;
    return min(qmin(lo, hi, 2 * ind, L, M),
               qmin(lo, hi, 2 * ind + 1, M + 1, R));
  }
  void upd(int lo, int hi, int inc, int ind = 1, int L = 0, int R = sz - 1) {
    push(ind, L, R);
    if (hi < L || R < lo) return;
    if (lo <= L && R <= hi) {
      lazy[ind] = inc;
      push(ind, L, R);
      return;
    }
    int M = (L + R) / 2;
    upd(lo, hi, inc, 2 * ind, L, M);
    upd(lo, hi, inc, 2 * ind + 1, M + 1, R);
    pull(ind);
  }
};
LazySegTree<1 << 19> L;
void run_case() {
  long long int t, i, j, k, p, x, y, u, n, w;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    tv.push_back({x, y});
    m[x] = m[y + 1] = 0;
  }
  int co = 0;
  for (auto& a : m) a.second = co++;
  for (auto& a : tv) {
    a.first = m[a.first], a.second = m[a.second + 1] - 1;
    L.upd(a.first, a.second, 1);
  }
  for (int i = 0; i < tv.size(); i++) {
    if (L.qmin(tv[i].first, tv[i].second) != 1) {
      cout << i + 1 << endl;
      return;
    }
  }
  cout << -1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int t = 1;
  for (int T = 1; 1 < t + 1 ? T < t + 1 : T > t + 1;
       1 < t + 1 ? T += 1 : T -= 1) {
    run_case();
  }
  return 0;
}
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((long long)result * base) % mod;
    base = ((long long)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
