Problem: There are N stations in the city where JOI lives, and they are numbered 1, 2, ..., and N, respectively. In addition, there are M railway lines, numbered 1, 2, ..., and M, respectively. The railway line i (1 \ leq i \ leq M) connects station A_i and station B_i in both directions, and the fare is C_i yen.

JOI lives near station S and attends IOI high school near station T. Therefore, I decided to purchase a commuter pass that connects the two. When purchasing a commuter pass, you must specify one route between station S and station T at the lowest fare. With this commuter pass, you can freely get on and off the railway lines included in the specified route in both directions.

JOI also often uses bookstores near Station U and Station V. Therefore, I wanted to purchase a commuter pass so that the fare for traveling from station U to station V would be as small as possible.

When moving from station U to station V, first select one route from station U to station V. The fare to be paid on the railway line i included in this route is

* If railway line i is included in the route specified when purchasing the commuter pass, 0 yen
* If railway line i is not included in the route specified when purchasing the commuter pass, C_i yen



It becomes. The total of these fares is the fare for traveling from station U to station V.

I would like to find the minimum fare for traveling from station U to station V when the route specified when purchasing a commuter pass is selected successfully.

Task

Create a program to find the minimum fare for traveling from station U to station V when you have successfully selected the route you specify when purchasing a commuter pass.

input

Read the following input from standard input.

* Two integers N and M are written on the first line. These indicate that there are N stations and M railroad lines in the city where JOI lives.
* Two integers S and T are written on the second line. These indicate that JOI purchases a commuter pass from station S to station T.
* Two integers U and V are written on the third line. These indicate that JOI wants to minimize the fare for traveling from station U to station V.
* Three integers A_i, B_i, and C_i are written in the i-th line (1 \ leq i \ leq M) of the following M lines. These indicate that the railway line i connects station A_i and station B_i in both directions, and the fare is C_i yen.



output

Output the minimum fare for traveling from station U to station V on one line to the standard output when the route from station S to station T is properly specified when purchasing a commuter pass.

Limits

All input data satisfy the following conditions.

* 2 \ leq N \ leq 100 000.
* 1 \ leq M \ leq 200 000.
* 1 \ leq S \ leq N.
* 1 \ leq T \ leq N.
* 1 \ leq U \ leq N.
* 1 \ leq V \ leq N.
* S ≠ T.
* U ≠ V.
* S ≠ U or T ≠ V.
* You can reach any other station from any station using one or more railway lines.
* 1 \ leq A_i <B_i \ leq N (1 \ leq i l \ leq M).
* 1 For \ leq i <j \ leq M, A_i ≠ A_j or B_i ≠ B_j.
* 1 \ leq C_i \ leq 1 000 000 000 (1 \ leq i \ leq M).



Input / output example

Input example 1


6 6
1 6
14
1 2 1
2 3 1
3 5 1
2 4 3
4 5 2
5 6 1


Output example 1


2


In this input example, the route that can be specified when buying a commuter pass is limited to the route of station 1-> station 2-> station 3-> station 5-> station 6.

To minimize the fare for traveling from station 1 to station 4, choose the route station 1-> station 2-> station 3-> station 5-> station 4. If you choose this route, the fare to be paid on each railway line is

* 2 yen for railway line 5 connecting station 4 and station 5.
* 0 yen for other railway lines.



Therefore, the total fare is 2 yen.

Input example 2


6 5
1 2
3 6
1 2 1000000000
2 3 1000000000
3 4 1000000000
4 5 1000000000
5 6 1000000000


Output example 2


3000000000


In this input example, the commuter pass is not used to move from station 3 to station 6.

Input example 3


8 8
5 7
6 8
1 2 2
2 3 3
3 4 4
1 4 1
1 5 5
2 6 6
3 7 7
4 8 8


Output example 3


15


Input example 4


5 5
1 5
twenty three
1 2 1
2 3 10
2 4 10
3 5 10
4 5 10


Output example 4


0


Input example 5


10 15
6 8
7 9
2 7 12
8 10 17
1 3 1
3 8 14
5 7 15
2 3 7
1 10 14
3 6 12
1 5 10
8 9 1
2 9 7
1 4 1
1 8 1
2 4 7
5 6 16


Output example 5


19





Creative Commons License
Information Olympics Japan Committee work "17th Japan Information Olympics (JOI 2017/2018) Final Selection"





Example

Input

6 6
1 6
1 4
1 2 1
2 3 1
3 5 1
2 4 3
4 5 2
5 6 1


Output

2

Solution (in CPP):

Solution:
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, dp[4][200000];
Pll a[400000], b[400000];
vector<LL> d, dp1, d_p, d_q;
string str, ss;
bool f;
char c[3000][3000];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<Edge>>vec;
vector<edge>ed;
//vector<LL>v;
map<Pll, LL>ma;
multiset<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
vector<LL> dijk(vector<vector<Edge>> &g, LL s) {
	vector<LL>dis(g.size());
	rep(i, g.size()) {
		dis[i] = INF;
	}
	dis[s] = 0;
	priority_queue<Pll, vector<Pll>, greater<Pll>>pq;
	pq.push(Pll(0, s));
	while (!pq.empty()) {
		Pll num = pq.top();
		pq.pop();
		LL v = num.sec, cost = num.fir;
		if (dis[v] < cost)continue;
		rep(i, g[v].size()) {
			if (dis[g[v][i].to] > dis[v] + g[v][i].cost) {
				dis[g[v][i].to] = dis[v] + g[v][i].cost;
				pq.push(Pll(dis[g[v][i].to], g[v][i].to));
			}
		}
	}
	return dis;
}

LL dfs(LL s, LL p_cos, LL q_cos) {
	LL ret = min({ p_cos + d_q[s], q_cos + d_p[s], p_cos + q_cos });
	rep(i, vec[s].size()) {
		LL next = vec[s][i].to;
		if (d[s] <= d[next])continue;
		if (d[s] == d[next] + vec[s][i].cost) {
			ret = min(ret, dfs(next, min(p_cos, d_p[next]), min(q_cos, d_q[next])));
		}
	}
	return ret;
}

int main() {
	cin >> n >> m;
	cin >> s >> t;
	cin >> p >> q;
	s--, t--, p--, q--;
	vec.resize(n);
	rep(i, m) {
		LL x, y, z;
		cin >> x >> y >> z;
		x--, y--;
		vec[x].push_back(Edge{ y,z });
		vec[y].push_back(Edge{ x,z });
		ed.push_back(edge{ x,y,z });
	}
	rep(i, 4) {
		rep(j, n)dp[i][j] = INF;
	}
	d = dijk(vec, s);
	d_p = dijk(vec, p);
	d_q = dijk(vec, q);
	priority_queue<Pll, vector<Pll>, greater<Pll>>pq;
	rep(i, m) {
		pq.push(Pll(min(d[ed[i].to], d[ed[i].from]), i));
	}
	dp[0][s] = d_p[s];
	dp[1][s] = d_q[s];
	dp[2][s] = d_p[s] + d_q[s];
	while (!pq.empty()) {
		Pll now = pq.top();
		pq.pop();
		LL  i = now.second, u = ed[i].to, v = ed[i].from;
		rep(j, 2) {
			if (d[u] + ed[i].cost == d[v]) {
				if (dp[0][u] + dp[1][u] < dp[2][v]) {
					dp[0][v] = min({ dp[0][u], d_p[v],dp[0][v] });
					dp[1][v] = min({ dp[1][u], d_q[v],	dp[1][v] });
				}
			}
			swap(u, v);
		}
	}
	rep(i, m) {
		pq.push(Pll(min(d[ed[i].to], d[ed[i].from]), i));
	}
	while (!pq.empty()) {
		Pll now = pq.top();
		pq.pop();
		LL  i = now.second, u = ed[i].to, v = ed[i].from;
		rep(j, 2) {
			if (d[u] + ed[i].cost == d[v]) {
				if (min({ dp[0][u], d_p[v] }) + min({ dp[1][u], d_q[v] }) < dp[2][v]) {
					dp[0][v] = min({ dp[0][u], d_p[v] });
					dp[1][v] = min({ dp[1][u], d_q[v] });
					dp[2][v] = dp[0][v] + dp[1][v];
				}
			}
			swap(u, v);
		}
	}
	//dp[0]+dp[1] uにpから,vにqから
	//cout << min(dfs(t, d_p[t], d_q[t]), d_p[q]) << endl;
	cout << min({ dp[2][t], d_p[q] }) << endl;
	return 0;
}