// Stephen Fulwider
//	Rapid Rerouting - BHCSI 2010 Programming Contest

import java.io.File;
import java.util.Arrays;
import java.util.Scanner;


public class reroute
{

	public static void main(String[] args) throws Exception
	{
		new reroute();
	}
	
	final int oo=(int)1e9; // infinity
	
	int N; // number vertices
	int[][] G=new int[100][100]; // adj. matrix
	
	reroute() throws Exception
	{
		Scanner in=new Scanner(new File("reroute.in"));
		for (int T=in.nextInt(),TC=1; T-->0; ++TC)
		{
			N=in.nextInt();
			
			// clear out adj matrix, set all distances to infinity except a node to itself
			for (int i=0; i<N; ++i)
			{
				Arrays.fill(G[i], 0, N, oo);
				G[i][i]=0;
			}
			
			// get distances
			for (int R=in.nextInt(); R-->0; )
			{
				int a=in.nextInt()-1; // sub 1 for 0-based
				int b=in.nextInt()-1;
				int c=in.nextInt();
				G[a][b]=G[b][a]=c;
			}
			
			// get start, dest, and wrong
			int s=in.nextInt()-1;
			int d=in.nextInt()-1;
			int w=in.nextInt()-1;
			
			// run floyds all pairs shortest path algo
			for (int k=0; k<N; ++k)
				for (int i=0; i<N; ++i)
					for (int j=0; j<N; ++j)
						G[i][j]=Math.min(G[i][j], G[i][k]+G[k][j]);
			
			// get the time we took, which is the shortest path from s->w + w->d
			int took=G[s][w]+G[w][d];
			
			// get the time we should have taken, which is just the shortest path from s->d
			int should=G[s][d];
			
			// print output
			System.out.printf("Case #%d: Took %d minutes, should have taken %d minutes%n", TC,took,should);
		}
	}

}
