1860
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cmath>
#define mem(x,y) memset(x,y,sizeof(x))
#define max(a,b) a>b?a:b
using namespace std;
const int N=110;
const int M=220;
const double Max=0x3f3f3f3f;
struct node
{
int beg;
int end;
double r,c;
};
node pp[M];
double dis[N];
int n,m,e,fn;
double fu;
void addedg(int beg,int end,double r,double c)
{
pp[e].beg=beg;
pp[e].end=end;
pp[e].r=r;
pp[e].c=c;
++e;
}
bool relax(int p)
{
double t=(dis[pp[p].beg]-pp[p].c)*pp[p].r;
if(t>dis[pp[p].end])
{
dis[pp[p].end]=t;
return true;
}
return false;
}
bool bellman_ford()
{
bool flag;
for(int i=0;i<n;i++)
dis[i]=0.0;
dis[fn]=fu;
for(int i=0;i<n-1;++i)
{
flag=false;
for(int j=0;j<e;++j)
{
if(relax(j))
flag=true;
}
if(dis[fn]>fu)
return true;
if(!flag)
return false;
}
for(int i=0;i<e;i++)
{
if(relax(i))
return true;
}
return false;
}
int main()
{
int beg,end;
double r1,r2,c1,c2;
scanf("%d%d%d%lf",&n,&m,&fn,&fu);
--fn;
e=0;
for(int i=0;i<m;i++)
{
scanf("%d%d%lf%lf%lf%lf",&beg,&end,&r1,&c1,&r2,&c2);
--beg;
--end;
addedg(beg,end,r1,c1);
addedg(end,beg,r2,c2);
}
bool ans=bellman_ford();
if(ans)
printf("YES\n");
else
printf("NO\n");
system("pause");
return 0;
}