PSU Campuses

No attempts yetTime limit1sMemory limit128 MB

Problem

Prince of Songkla University (PSU) runs five campuses in the south of Thailand: Hatyai (H), Pattani (P), Suratthani (S), Phuket (K) and Trang (T). The distances between the campuses are in the table below.

CampusesDistance (km)CampusesDistance (km)
Hatyai - Pattani103Pattani - Phuket577
Hatyai - Suratthani329Pattani - Trang260
Hatyai - Phuket466Suratthani - Phuket287
Hatyai - Trang148Suratthani - Trang226
Pattani - Suratthani408Phuket - Trang312

When the president of PSU goes on a mission through several campuses, he or she wants to know the total distance of the mission. A mission always starts at the Hatyai campus, and once the mission ends the president returns from the last campus straight back to Hatyai.

Given the order of campuses of one mission, write a program that computes the total distance of that mission. The same campus can appear twice in a row, and then the distance between the two is 0.

Input

The first line contains the number of missions nn (1n1001 \le n \le 100). Each of the next nn lines describes one mission. A mission is given as a string made only of the characters H, P, S, K and T, and the president visits the campuses in the order written in that string. The Hatyai campus is always both the starting point and the end point, so H is not written at the beginning or at the end of the string. H can still appear as an intermediate campus. Each string has length between 1 and 10.

Output

For each mission print one line in the form Case i: d, where ii is the mission number starting from 1 and dd is the total distance of that mission in kilometres. Put exactly one space after the colon.