You are given an undirected unweighted graph consisting of $n$ vertices and $m$ edges (which represents the map of Bertown) and the array of prices $p$ of length $m$. It is guaranteed that there is a path between each pair of vertices (districts).

Mike has planned a trip from the vertex (district) $a$ to the vertex (district) $b$ and then from the vertex (district) $b$ to the vertex (district) $c$. He can visit the same district twice or more. But there is one issue: authorities of the city want to set a price for using the road so if someone goes along the road then he should pay the price corresponding to this road (he pays each time he goes along the road). The list of prices that will be used $p$ is ready and they just want to distribute it between all roads in the town in such a way that each price from the array corresponds to exactly one road.

You are a good friend of Mike (and suddenly a mayor of Bertown) and want to help him to make his trip as cheap as possible. So, your task is to distribute prices between roads in such a way that if Mike chooses the optimal path then the price of the trip is the minimum possible. Note that you cannot rearrange prices after the start of the trip.

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 10^4$) — the number of test cases. Then $t$ test cases follow.

The first line of the test case contains five integers $n, m, a, b$ and $c$ ($2 \le n \le 2 \cdot 10^5$, $n-1 \le m \le min(\frac{n(n-1)}{2}, 2 \cdot 10^5)$, $1 \le a, b, c \le n$) — the number of vertices, the number of edges and districts in Mike's trip.

The second line of the test case contains $m$ integers $p_1, p_2, \dots, p_m$ ($1 \le p_i \le 10^9$), where $p_i$ is the $i$-th price from the array.

The following $m$ lines of the test case denote edges: edge $i$ is represented by a pair of integers $v_i$, $u_i$ ($1 \le v_i, u_i \le n$, $u_i \ne v_i$), which are the indices of vertices connected by the edge. There are no loops or multiple edges in the given graph, i. e. for each pair ($v_i, u_i$) there are no other pairs ($v_i, u_i$) or ($u_i, v_i$) in the array of edges, and for each pair $(v_i, u_i)$ the condition $v_i \ne u_i$ is satisfied. It is guaranteed that the given graph is connected.

It is guaranteed that the sum of $n$ (as well as the sum of $m$) does not exceed $2 \cdot 10^5$ ($\sum n \le 2 \cdot 10^5$, $\sum m \le 2 \cdot 10^5$).


-----Output-----

For each test case, print the answer — the minimum possible price of Mike's trip if you distribute prices between edges optimally.


-----Example-----
Input
2
4 3 2 3 4
1 2 3
1 2
1 3
1 4
7 9 1 5 7
2 10 4 8 5 6 7 3 3
1 2
1 3
1 4
3 2
3 5
4 2
5 6
1 7
6 7

Output
7
12



-----Note-----

One of the possible solution to the first test case of the example:

[Image]

One of the possible solution to the second test case of the example:

[Image]

Difficulty: introductory

Starter code:

Solutions:
import sys
from collections import deque
input = sys.stdin.readline

t = int(input())
for _ in range(t):
    n, m, a, b, c = list(map(int,input().split()))
    p = list(map(int, input().split()))
    p.sort()
    
    pref = [0]
    curr = 0
    for i in range(m):
        curr += p[i]
        pref.append(curr)

    adj = [[] for i in range(n)]
    for _ in range(m):
        u, v = list(map(int,input().split()))
        adj[u - 1].append(v - 1)
        adj[v - 1].append(u - 1)

        
    aD = [-1] * n
    bD = [-1] * n
    cD = [-1] * n

    for i in range(3):
        q = deque()
        q.append(([a,b,c][i]-1,0))
        l = [aD,bD,cD][i]
        l[q[0][0]] = 0
        while q:
            v, d = q.popleft()
            for nex in adj[v]:
                if l[nex] == -1:
                    l[nex] = d + 1
                    q.append((nex,d+1))
    poss = []
    for i in range(n):
        if aD[i] + bD[i] + cD[i] <= m:
            poss.append(pref[aD[i] + bD[i] + cD[i]] + pref[bD[i]])
    print(min(poss))
            


import sys
from collections import deque
def input():
	return sys.stdin.readline()[:-1]

INF = 10**6
t = int(input())
for _ in range(t):
	n, m, a, b, c = map(int, input().split())
	a, b, c = a-1, b-1, c-1
	p = list(map(int, input().split()))
	p.sort()
	cum = [0 for _ in range(m+1)]
	for i, x in enumerate(p):
		cum[i+1] = cum[i] + x
	adj = [[] for _ in range(n)]
	for _ in range(m):
		u, v = map(int, input().split())
		adj[u-1].append(v-1)
		adj[v-1].append(u-1)

	a_dist, b_dist, c_dist = [INF for _ in range(n)], [INF for _ in range(n)], [INF for _ in range(n)]

	a_dist[a] = 0
	q = deque([a])
	while q:
		l = q.popleft()
		for v in adj[l]:
			if a_dist[v] > a_dist[l]+1:
				a_dist[v] = a_dist[l]+1
				q.append(v)

	b_dist[b] = 0
	q = deque([b])
	while q:
		l = q.popleft()
		for v in adj[l]:
			if b_dist[v] > b_dist[l]+1:
				b_dist[v] = b_dist[l]+1
				q.append(v)

	c_dist[c] = 0
	q = deque([c])
	while q:
		l = q.popleft()
		for v in adj[l]:
			if c_dist[v] > c_dist[l]+1:
				c_dist[v] = c_dist[l]+1
				q.append(v)
	
	#print(a_dist)
	#print(b_dist)
	#print(c_dist)
	ans = 10**20
	for i in range(n):
		aa, bb, cc = a_dist[i], b_dist[i], c_dist[i]
		#print(aa, bb, cc)
		if aa+bb+cc > m:
			continue
		ans = min(ans, cum[aa+bb+cc] + cum[bb])
	print(ans)

import sys
input = sys.stdin.readline
from itertools import accumulate
from collections import deque

def bfs(x):
    DIS=[-1]*(n+1)
    Q=deque([x])
    DIS[x]=0
    
    while Q:
        x=Q.pop()
        for to in E[x]:
            if DIS[to]==-1:
                DIS[to]=DIS[x]+1
                Q.appendleft(to)
    return DIS
                

t=int(input())
for tests in range(t):
    n,m,a,b,c=list(map(int,input().split()))
    P=sorted(map(int,input().split()))
    S=[0]+list(accumulate(P))

    E=[[] for i in range(n+1)]
    for i in range(m):
        x,y=list(map(int,input().split()))
        E[x].append(y)
        E[y].append(x)

    DIS_A=bfs(a)
    DIS_B=bfs(b)
    DIS_C=bfs(c)

    ANS=1<<63

    #print(S)

    if DIS_A[b]+DIS_B[c]<=m and ANS>S[DIS_A[b]+DIS_B[c]]:
        ANS=S[DIS_A[b]+DIS_B[c]]

    for i in range(1,n+1):
        d2=DIS_B[i]
        d1=DIS_A[i]+DIS_C[i]

        #print(i,d1,d2)

        if d1+d2>m:
            continue

        if ANS>S[d2]*2+S[d1+d2]-S[d2]:
            ANS=S[d2]*2+S[d1+d2]-S[d2]

        #print(ANS)
        

    print(ANS)

    

    
        
            



from collections import deque
import sys
input = sys.stdin.readline
inf = int(1e9)
for i in range(int(input())):
    n, m, a, b, c = list(map(int, input().split()))
    a -= 1
    b -= 1
    c -= 1
    cost = list(map(int, input().split()))
    g = [[] for _ in range(n)]
    for i in range(m):
        a2, b2 = list(map(int, input().split()))
        g[a2 - 1].append(b2 - 1)
        g[b2 - 1].append(a2 - 1)
    def bfs(st):
        Q = deque(maxlen=n)
        lv = [-1] * n
        Q.append(st)
        lv[st] = 0
        while Q:
            cur = Q.popleft()
            for to in g[cur]:
                if lv[to] == -1:
                    lv[to] = lv[cur] + 1
                    Q.append(to)
        return lv
    lvA = bfs(a)
    lvB = bfs(b)
    lvC = bfs(c)
    # print(lvA, lvB, lvC)
    ans = int(1e18)
    cost.sort()
    cost.insert(0, 0)
    for i in range(1, len(cost)):
        cost[i] += cost[i - 1]
    # print(cost)
    for i in range(n):
        d1 = lvB[i]
        d2 = lvA[i] + lvC[i]
        if d1 + d2 >= len(cost):
            continue
        # print(f'i={i}, d1={d1}, d2={d2}')
        ans = min(ans, cost[d1] * 2 + cost[d1 + d2] - cost[d1])
    print(ans)