// Arup Guha
// 10/20/12 - 10/24/12
// Solution to Greater NY Regional Problem B: Conversions
import java.util.*;

public class b {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		int n = stdin.nextInt();

		for (int loop=1; loop<=n; loop++) {
			
			double val = stdin.nextDouble();
			String unit = stdin.next();
			System.out.printf("%d ", loop);

			// Use their chart exactly for all four cases.
			if (unit.equals("kg")) {
				System.out.printf( "%.4f lb\n", (2.2046*val));
			}
			else if (unit.equals("lb")) {
				System.out.printf( "%.4f kg\n", val*0.4536);
			}
			else if (unit.equals("l")) {
				System.out.printf( "%.4f g\n", val*0.2642);
			}
			else {
				System.out.printf( "%.4f l\n", val*3.7854);
			}

		}
	}
}