U.S. Unit Conversion

Interview

Time limit1sMemory limit128 MB

Summary
Convert given values between kilograms/pounds and liters/gallons using fixed conversion factors, rounding to four decimal places.
Level

Easy2 of 10

Topics
Implementation, Math
Solved
No attempts yet

Problem

The United States commonly uses a different unit system from the metric system used in Korea. Write a program that converts between the following metric and U.S. customary units.

Only these conversions are needed: kilograms ↔ pounds and liters ↔ gallons. Use the values in the table below.

KindMetricU.S. customary
Weight1.0000 kilogram2.2046 pounds
0.4536 kilograms1.0000 pound
Volume1.0000 liter0.2642 gallons
3.7854 liters1.0000 gallon

Input

The first line contains the number of test cases, T (1 <= T <= 1,000).

Each test case is given on one line. The first token is a value, and the second token is a unit. The value may be a decimal number and, if so, has at most four digits after the decimal point. The unit is one of kg, lb, l, and g, meaning kilograms, pounds, liters, and gallons, respectively.

Output

For each test case, print the converted value and unit. Round the value to exactly four digits after the decimal point.

The output unit is one of kg, lb, l, and g, using the same meanings as in the input description.

Examples1

  1. Example 1

    Input
    5
    1 kg
    2 l
    7 lb
    3.5 g
    0 l
    
    Expected output
    2.2046 lb
    0.5284 g
    3.1752 kg
    13.2489 l
    0.0000 g