//Rosa Enciso
// Solution to 2007 BHCSI Contest #3 Problem time

import java.io.*;
import java.util.*;

public class train
{

	public static void main (String [] args) throws IOException
	{
		
		Scanner input = new Scanner(new File("train.in"));
		
		int numcases = input.nextInt();
		
		// Loop through all of the cases.
		for (int mycase=0; mycase<numcases; mycase++) {
		
			// Read in all of the input for this case.
			String location = input.next();
			String point_a = input.next();
			String point_b = input.next();
			int distance = input.nextInt();
			int speed = input.nextInt();
			double time;
		
			// This is the only calculation you need!
			time = (double)distance/speed;
		
			// Traveling from A to B at n mph takes T hours.
		
			if(location.equals("US"))
			{
				System.out.println("Traveling from "+ point_a + " to " + point_b + " at " + speed +" mph takes "+ time +" hours.");	
			}
			else
			{
				System.out.println("Traveling from "+ point_a + " to " + point_b + " at " + speed +" kph takes "+ time +" hours.");	
			}
			
		}
		
		input.close();
	}	
}