#include <bits/stdc++.h>

using namespace std;

#define endl "\n"



int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);
   
    long long int n,p,x,a,i,mn=INT_MAX;
    cin>>n;
    float time=0.5;
    for(i=0;i<n;++i)
    {
        cin>>a>>p>>x;
        if(((float)x)>ceil(((float)a-0.5)))
            mn=min(mn,p);
        
    }
    
    if(mn!=INT_MAX)
       cout<<mn;
       
    else
       cout<<-1;
     return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef long long ll;

#define printV(v) for(int i = 0;i < v.size();++i)cout << v[i] << endl
#define print(x) cout << x << endl

int main() {
	int N,M,T;
  cin >> N;
  cin >> M;
  cin >> T;
  int n = N;
  int t = 0;
  bool ok = true;
	for(int i = 0;i < M;++i){
		int A,B;
      cin >> A;
      n -= A - t;
      if(n <= 0){
        ok = false;
        break;
      }
      cin >> B;
      n += B - A;
      if(n >= N){
        n = N;
      }
      t = B;
      //print(n);
      //print(t);
    }
  //print(n);
	n -= (T - t);
      if(n <= 0){
        ok = false;
      }
  //print(n);
  print((ok?"Yes":"No"));
}
