#include <iostream> #include <cstdio> #include <map> #include <cstring> #include <string> #include <vector> #include <cmath> #include <algorithm> using namespace std; struct edge { int s,e; double commission; double rate; }; int main() { int n,m,s; double v; int i,j; struct edge e[205]; double d[105]={0}; scanf("%d%d%d%lf",&n,&m,&s,&v); for (i=0;i<m;i++) { int a,b; double Rab,Cab,Rba,Cba; scanf("%d%d%lf%lf%lf%lf",&a,&b,&Rab,&Cab,&Rba,&Cba); e[i].s=a; e[i].e=b; e[i].commission=Cab; e[i].rate=Rab; e[i+m].s=b; e[i+m].e=a; e[i+m].commission=Cba; e[i+m].rate=Rba; } bool flag=false; d[s]=v; for (i=0;i<n;i++) for (j=0;j<2*m;j++) { if ( (d[e[j].s]-e[j].commission)*e[j].rate > d[e[j].e] ) { d[e[j].e]=(d[e[j].s]-e[j].commission)*e[j].rate; if (i==n-1) flag=true; } } if (flag) printf("YES\n"); else printf("NO\n"); }