#include <iostream>
#include <vector>
#include <cstdlib>
#include <set>
#include <iostream>
#include <iomanip>
#include<stdio.h>
#include<climits>
#include<vector>
#include<algorithm>
#include <cmath>
#include<map>
#include<deque>
#include<set>
#include<queue>
#include<cassert>
#include<functional>
#include<numeric>
#include<regex>
 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// 入力

int main() {
long long n,m,t,b;
  cin >> n >> m >> t;
bool flag = true;
long long d[m][2];
  for(int i=0;i<m;i++){
  cin >> d[i][0] >> d[i][1];
  }

b=n-d[0][0];
  //cout << b << endl;
if(b<=0) flag=false;
b+=d[0][1]-d[0][0];
if(b>=n)b=n;
  //cout << b << endl;
for(int i=1;i<m;i++){
b-=d[i][0]-d[i-1][1];
if(b<=0){
flag=false;
break;  
}    //cout << b << endl;

b+=d[i][1]-d[i][0];
if(b>=n)b=n;
}
  //cout << b << endl;
b-=t-d[m-1][1];  
if(b<=0){
flag=false; 
}
  //cout << b << endl;
if(flag==false){
  cout << "No" << endl;
}
else cout << "Yes" << endl; 
}
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#define itn int
#define ll long long
#define pir pair<ll,ll>
#define yes {puts("Yes");}
#define no {puts("No");}
using namespace std;

ll read(){
	ll a=0,b=1;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();}
	while(c>='0'&&c<='9')a=a*10+c-48,c=getchar();
	return a*b;
}

int n,m;
struct edge{
	int v,nx;
	ll c,d;
}e[200005];
int cnt,hd[100005];

ll dis[100005];
bool vis[100005];

struct node{
	int i;
	ll w;
};
bool operator<(node a,node b){
	return a.w>b.w;
}

ll clac(ll t,ll c,ll d){
	if(!d)return c;
	ll sq=sqrt(d+2),ans=c+d/(t+1);
	for(ll st=t;st<=t+3;st++){
		ans=min(ans,d/(st+1)+st-t+c);
	}
	if(t+1<sq){
		for(ll st=t;st<=t+30;st++){
			ans=min(ans,d/(st+1)+st-t+c);
		}
		for(ll st=max(t,sq-30);st<=sq+5;st++){
			ans=min(ans,d/(st+1)+st-t+c);
		}
	}
	return ans;
}

void dij(){
	memset(dis,0x3f,sizeof dis);
	dis[1]=0;
	priority_queue<node>q;
	q.push(node{1,0});
	while(!q.empty()){
		node t=q.top();q.pop();
		if(vis[t.i])continue;
		vis[t.i]=1;
		for(int i=hd[t.i];i;i=e[i].nx){
			int v=e[i].v;
			ll w=clac(dis[t.i],e[i].c,e[i].d);
			if(dis[v]>dis[t.i]+w){
				dis[v]=dis[t.i]+w;
				q.push(node{v,dis[v]});
			}
		}
	}
}

int main(){
	n=read(),m=read();
	while(m--){
		int a=read(),b=read(),c=read(),d=read();
		e[++cnt]=edge{b,hd[a],c,d},hd[a]=cnt;
		e[++cnt]=edge{a,hd[b],c,d},hd[b]=cnt;
	}
	dij();
	if(dis[n]>1e18)cout<<-1;
	else cout<<dis[n]<<'\n';
	return 0;
}

