public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out = new StringBuilder();
		Dijkstra G = new Dijkstra(20000);
		int nTest = Integer.parseInt(in.readLine().trim());
		for (int tt = 0; tt < nTest; tt++) {
			int[] v = readInts(in.readLine());
			int n = v[0], m = v[1], s = v[2], t = v[3];
			G.init(n);
			for (int i = 0; i < m; i++) {
				int[] abw = readInts(in.readLine());
				G.union(abw[0], abw[1], abw[2], true);
			}
			G.dijkstra(s);
			out.append("Case #" + (tt + 1) + ": ");
			if (G.dis[t] == G.INF)
				out.append("unreachable\n");
			else
				out.append(G.dis[t] + "\n");
		}
		System.out.print(out);
	}