#include <bits/stdc++.h>
using namespace std;
#define INF 1111111111111111
typedef long long ll;
struct gogo
{
    ll to,nt,st;
};
ll n,m,x,y,a,b,t,k,d[101010];
vector<gogo> vec[101010];
void bfs()
{
    queue<ll>que;
    que.push(x);
    while(!que.empty())
    {
        int from=que.front();
        que.pop();
        for(ll i=0; i<vec[from].size(); i++)
        {
            ll to=vec[from][i].to;

            {
                if(d[to]>((d[from]-1+vec[from][i].st)/vec[from][i].st)*vec[from][i].st+vec[from][i].nt)
                {
                    d[to]=((d[from]-1+vec[from][i].st)/vec[from][i].st)*vec[from][i].st+vec[from][i].nt;
                    if(to!=y)que.push(to);
                }
            }
            /*else
            {
                if(d[to]>d[from]+vec[from][i].nt)
                {
                    d[to]=d[from]+vec[from][i].nt;
                }
            }*/
        }
    }
}
int main()
{
    scanf("%lld%lld%lld%lld",&n,&m,&x,&y);
    for(ll i=0; i<m; i++)
    {
        scanf("%lld%lld%lld%lld",&a,&b,&t,&k);
        gogo gogo1,gogo2;
        gogo1.to=b;
        gogo1.nt=t;
        gogo1.st=k;
        gogo2.to=a;
        gogo2.nt=t;
        gogo2.st=k;
        vec[a].push_back(gogo1);
        vec[b].push_back(gogo2);
    }
    for(ll i=0; i<=n; i++)d[i]=INF;
    d[x]=0;
    bfs();
    //for(ll i=0;i<=4;i++)printf("%lld\n",d[i]);
    if(d[y]!=INF)printf("%lld",d[y]);
    else printf("-1");
    return 0;
}

#include "bits/stdc++.h"
using namespace std;
typedef long long li;



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    const li n = 4;
    vector<li> xs(n);
    for (int i = 0; i < n; ++i) {
        cin >> xs[i];
    }
    const li sum = accumulate(xs.begin(), xs.end(), 0LL);
    bool ok = false;
    for (int mask = 0; mask < 1 << n; ++mask) {
        li subsum = 0;
        for (int i = 0; i < n; ++i) {
            if ((mask >> i) & 1) {
                subsum += xs[i];
            }
        }
        ok |= subsum == sum - subsum;
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}