#include <bits/stdc++.h>
namespace fastIO {
bool IOerror = 0;
inline char nc() {
  static char buf[100000], *p1 = buf + 100000, *pend = buf + 100000;
  if (p1 == pend) {
    p1 = buf;
    pend = buf + fread(buf, 1, 100000, stdin);
    if (pend == p1) {
      IOerror = 1;
      return -1;
    }
  }
  return *p1++;
}
inline bool blank(char ch) {
  return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}
inline void read(int &x) {
  char ch;
  while (blank(ch = nc()))
    ;
  if (IOerror) return;
  for (x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0')
    ;
}
};  // namespace fastIO
template <class T>
inline T lowbit(T x) {
  return x & (-x);
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline bool scan(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
const double pi = 3.14159265358979323846264338327950288L;
using namespace std;
int n;
vector<int> num;
pair<int, int> a[200005];
int c[800005], cnt[800005];
void add(int x, int num) {
  for (int i = x; i > 0; i -= lowbit(i)) {
    c[i] += num;
  }
}
int sum(int x) {
  int ans = 0;
  for (int i = x; i < 800005; i += lowbit(i)) ans += c[i];
  return ans;
}
int dp[800005][21];
void rmq_init() {
  int n = 800005 - 1;
  for (int i = 0; i < n; i++) dp[i][0] = cnt[i];
  for (int j = 1; (1 << j) <= n; j++) {
    for (int i = 0; i + (1 << j) - 1 < n; i++) {
      dp[i][j] = min(dp[i][j - 1], dp[i + (1 << (j - 1))][j - 1]);
    }
  }
}
int rmq(int l, int r) {
  int k = 0;
  while ((1 << (k + 1)) <= r - l + 1) k++;
  return min(dp[l][k], dp[r - (1 << k) + 1][k]);
}
map<int, int> mp;
void solve() {
  mp.clear();
  int cnt = 0, sz = num.size();
  for (int i = 0; i < sz - 1; i++) {
    if (num[i] + 1 == num[i + 1]) {
      mp[num[i]] = ++cnt;
    } else {
      mp[num[i]] = ++cnt;
      ++cnt;
    }
  }
  mp[num[sz - 1]] = ++cnt;
}
int main() {
  memset(c, 0, sizeof(c));
  num.clear();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].first, &a[i].second);
    num.push_back(a[i].first);
    num.push_back(a[i].second);
  }
  sort(num.begin(), num.end());
  num.erase(unique(num.begin(), num.end()), num.end());
  solve();
  for (int i = 1; i <= n; i++) {
    a[i].first = mp[a[i].first];
    a[i].second = mp[a[i].second];
    add(a[i].first - 1, -1);
    add(a[i].second, 1);
  }
  for (int i = 1; i < 800005; i++) {
    cnt[i - 1] = sum(i);
  }
  rmq_init();
  for (int i = 1; i <= n; i++) {
    if (rmq(a[i].first - 1, a[i].second - 1) >= 2) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
