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 <bits/stdc++.h>

using namespace std;

#define MP make_pair
#define FF first
#define SS second

using LL = long long;
using PII = pair<int,int>;
using PLL = pair<LL,LL>;
using PILL = pair<LL,PII>;

const LL INF = 1e15;
const int UB = 400010;

int N, M, S, Gl;
map<PLL,int> ids;
LL dist[UB];
void dijk(vector<vector<PLL>>& G){
  priority_queue<PLL, vector<PLL>, greater<PLL>> pq;
  fill(dist, dist+UB, INF);
  pq.push(PLL(0,ids[MP(S,0)]));
  dist[ids[MP(S,0)]] = 0;

  while(!pq.empty()){
	PLL p = pq.top();
	pq.pop();
	if(p.FF > dist[p.SS])
	  continue;
	  
	for(auto&& e: G[p.SS]){
	  if(p.FF + e.SS < dist[e.FF]){
		dist[e.FF] = p.FF + e.SS;
		pq.push(MP(dist[e.FF], e.FF));
	  }
	}
  }
}

int main(){
  cin >> N >> M >> S >> Gl;
  --S;
  --Gl;
  int id = 0;
  
  vector<vector<int>> tms(N);
  ids[MP(0,S)] = id++;
  tms[S].push_back(0);
  vector<vector<PLL>> G(UB);
  for(int i=0;i<M;++i){
	int u, v, t, c;
	cin >> u >> v >> t >> c;
	--u;
	--v;
	if(!ids.count(MP(u,t)))
	  ids[MP(u,t)] = id++;
	if(!ids.count(MP(v,t+c)))
	  ids[MP(v,t+c)] = id++;
	tms[u].push_back(t);
	tms[v].push_back(t+c);
	G[ids[MP(u,t)]].emplace_back(ids[MP(v,t+c)], 0);
  }

  for(int i=0;i<N;++i){
	sort(begin(tms[i]), end(tms[i]));
	tms[i].erase(unique(begin(tms[i]), end(tms[i])), end(tms[i]));
	for(int j=0;j+1<tms[i].size();++j){
	  G[ids[MP(i,tms[i][j])]].emplace_back(ids[MP(i,tms[i][j+1])], tms[i][j+1] - tms[i][j]);
	}
  }

  dijk(G);
  LL ans = INF;
  for(auto&& t: tms[Gl])
	ans = min(ans, dist[ids[MP(Gl,t)]]);
  cout << ans << endl;
  
  return 0;
}