#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> s(M), c(M), _s(M);
  for (ll(i) = (0), i_len = (M); (i) < (i_len); ++(i)) {
    cin >> s[i] >> c[i];
    _s[i] = s[i];
  }
  sort((_s).begin(), (_s).end());
  ll D = _s[M - 1];
  return 0;
}
