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.
| Campuses | Distance (km) | Campuses | Distance (km) |
|---|---|---|---|
| Hatyai - Pattani | 103 | Pattani - Phuket | 577 |
| Hatyai - Suratthani | 329 | Pattani - Trang | 260 |
| Hatyai - Phuket | 466 | Suratthani - Phuket | 287 |
| Hatyai - Trang | 148 | Suratthani - Trang | 226 |
| Pattani - Suratthani | 408 | Phuket - Trang | 312 |
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.
The first line contains the number of missions n (1≤n≤100). Each of the next n 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.
For each mission print one line in the form Case i: d, where i is the mission number starting from 1 and d is the total distance of that mission in kilometres. Put exactly one space after the colon.