P27907 [洛谷] [GESP202312 Level 3] Unit Conversion
普及-
题目描述

Problem Description

Xiao Yang's math homework this week involves unit conversion, and since he enjoys programming, he decides to use it to help solve these problems.

Xiao Yang has only learned about length and weight units, specifically:

  • Length units include kilometers (km), meters (m), and millimeters (mm). Their relationships are: $1\text{km} = 1000\text{m} = 1000000\text{mm}$.

  • Weight units include kilograms (kg), grams (g), and milligrams (mg). Their relationships are: $1\text{kg} = 1000\text{g} = 1000000\text{mg}$.

Xiao Yang's homework only involves converting larger units to smaller units. That is, Xiao Yang's homework will only include the following types of questions: meters to millimeters, kilometers to millimeters, kilometers to meters, grams to milligrams, kilograms to milligrams, kilograms to grams.

Now, please help complete the unit conversion program.

Input Format

The first line of input is an integer representing the number of questions.

Next, there are $N$ lines, each containing a string representing a unit conversion question, in the format $x$ unit $1 = ?$ unit $2$. Here, $x$ is a non-negative integer not exceeding $1000$, and unit $1$ and unit $2$ are the English abbreviations for the two units. It is guaranteed that they are either both length units or both weight units, and unit 1 is larger than unit 2.

For example, if the question requires you to convert $1\text{km}$ to $\text{mm}$, the input would be 1 km = ? mm.

It is guaranteed that $1 \leq N \leq 1000$.

Output Format

Output $N$ lines, each containing the answer to the corresponding question. When outputting, simply replace the ? in the input with the answer, and output the rest of the line exactly as it appears in the input. Since Xiao Yang's questions only involve converting larger units to smaller units and the input $x$ is an integer, the answer will also be an integer.

For example, if the question requires you to convert $1\text{km}$ to $\text{mm}$, the input would be 1 km = ? mm. You would then output 1 km = 1000000 mm.

Sample Input and Output

Sample Input #1

2
1 km = ? mm
1 m = ? mm

Sample Output #1

1 km = 1000000 mm
1 m = 1000 mm

Sample Input #2

5
100 m = ? mm
1000 km = ? m
20 kg = ? g
200 g = ? mg
0 kg = ? mg

Sample Output #2

100 m = 100000 mm
1000 km = 1000000 m
20 kg = 20000 g
200 g = 200000 mg
0 kg = 0 mg
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 1 km = ? mm 1 m = ? mm
样例输出
1 km = 1000000 mm 1 m = 1000 mm