#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int  long long
typedef vector<int> vi;
typedef pair<int, int> pii;

#define PI 3.14159265
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;

const int MAXN = 1000005, MAXK = 18;
int prime[MAXN];

void seive()
{
    
    
    for(int i=2;i<=MAXN;i++)
    {
        if(prime[i]==0)
        {
            for(int j=i;j<=MAXN;j+=i)
            {
              
                prime[j]++;
            }
        }
    }
}

 

int32_t main()
{
  
  int n;
  cin>>n;
  int a[n][3];
  for(int i=0;i<n;i++)
  {
      cin>>a[i][0]>>a[i][1]>>a[i][2];
      
  }
   
   int ans=INT_MAX;
   for(int i=0;i<n;i++)
   {
       double time=0.5+(a[i][2]-1)*1.0;
       
       if(time>(double)a[i][0])
       {
           ans=min(ans,a[i][1]);
       }
   }
   
   if(ans==INT_MAX)
   {
       cout<<-1;
   }
   else
   {
       cout<<ans;
   }
   
   
   
   
   
   
   
   
   
   
   
   
   

    return 0;
    
}
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

bool f(int N, int M, int T, const vi &A, const vi &B)
{
    int b = N;
    int t = 0;
    for (int i = 0; i < M; i++)
    {
        if ((A[i] - t) >= b)
        {
            return false;
        }
        else
        {
            b += (B[i] - 2 * A[i] + t);
            b = min(b, N);
            t = B[i];
        }
    }
    return (T - t) < b;    
}

int main()
{
    int N, M, T;
    io >> N >> M >> T;
    vi A(M), B(M);
    for (int i = 0; i < M; i++)
        io >> A[i] >> B[i];
    
    bool ans = f(N, M, T, A, B);
    io << YesNo(ans) << BR;
}

