problem

AOR Ika is at the $ S $ th bus stop at time $ 0 $ and wants to go from there to the $ G $ th bus stop. The number of bus stops $ N $ and $ M $ routes (*) connecting different bus stops are given. The bus stops are numbered $ 1, \ dots, and N $, respectively. Each route consists of $ 4 $ values: origin $ u $, destination $ v $, departure time $ t $, and travel time $ c $. You can catch the bus if you are at the departure $ u $ at the time $ t $ and arrive at the destination $ v $ at the time $ t + c $. While not on the bus, AOR Ika gets wet in the rain. When heading to the $ G $ th bus stop through the route that minimizes the time of getting wet in the rain, output the total time of getting wet in the rain from the time $ 0 $ to the arrival at the $ G $ th bus stop.

(*) In graph theory terms, a path is a sequence of vertices and edges, but please note that it is used here to mean edges.



input

Input is given from standard input in the following format.

$ N \ M \ S \ G $
$ u_1 \ v_1 \ t_1 \ c_1 $
$ \ vdots $
$ u_M \ v_M \ t_M \ c_M $

output

Print the minimum amount of time you get wet in one line. Also, output a line break at the end.

Example

Input

2 2 1 2
1 2 10 100
1 2 5 500


Output

5
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;//from,to,cost
map<P,int> Vertex;
vector<P> Time[100000];
vector<P> Graph[500000];//to,cost
int vc;
int main(){
    int N,M,S,G;
    cin>>N>>M>>S>>G;
    S--; G--;
    for(int i=0;i<N;i++){
        Vertex[P(i,0)]=vc;
        Time[i].emplace_back(0,vc);
        vc++;
    }
    for(int i=0;i<M;i++){
        int u,v,t,c;
        cin>>u>>v>>t>>c;
        u--; v--;
        if(!Vertex.count(P(u,t))){
            Vertex[P(u,t)]=vc;
            Time[u].emplace_back(t,vc);
            vc++;
        }
        if(!Vertex.count(P(v,t+c))){
            Vertex[P(v,t+c)]=vc;
            Time[v].emplace_back(t+c,vc);
            vc++;
        }
        Graph[Vertex[P(u,t)]].emplace_back(Vertex[P(v,t+c)],0);
    }

    for(int s=0;s<N;s++){
        sort(Time[s].begin(), Time[s].end());
        for(int i=1;i<Time[s].size();i++){
            Graph[Time[s][i-1].second].emplace_back(Time[s][i].second,Time[s][i].first-Time[s][i-1].first);
        }
    }
    vector<int> memo(vc+1,10000000);
    vector<bool> visited(vc+1,false);
    priority_queue<P,vector<P>,greater<P>> Q;
    Q.emplace(P(0,Vertex[P(S,0)]));
    while(!Q.empty()){
        int rain, v;
        tie(rain,v)=Q.top();Q.pop();
        if(visited[v]) continue;
        visited[v]=true;
        for(auto g:Graph[v]){
            int to,cost;
            tie(to,cost)=g;
            if(memo[to]>rain+cost){
                Q.emplace(rain+cost,to);
                memo[to]=rain+cost;
            }
        }
    }
    int ans = 1000000;
    for(auto t:Time[G]){
        ans=min(ans,memo[t.second]);
    }
    cout<<ans<<endl;
}