#t106. 单位转换
单位转换
Unit Conversion
Problem Description
Xiaoyang's math homework this week is about unit conversion, and since Xiaoyang likes programming, he decided to write a program to solve these problems.
Xiaoyang has only learned length units and weight units, specifically:
- Length units include kilometre (
km), metre (m), and millimetre (mm), with relationships: . - Weight units include kilogram (
kg), gram (g), and milligram (mg), with relationships: .
Xiaoyang's homework only involves converting a larger unit into a smaller unit, i.e. the problems only cover: metres to millimetres, kilometres to millimetres, kilometres to metres, grams to milligrams, kilograms to milligrams, and kilograms to grams.
Now please write a program to perform the unit conversions.
Input Format
The first line of input is an integer , the number of problems.
The following lines each contain a string describing a conversion problem, in the format $x$ unit1 = ? unit2. Here is a non-negative integer not exceeding , and unit1 and unit2 are the English abbreviations of two units; they are guaranteed to be both length units or both weight units, and unit1 is larger than unit2.
For example, if the problem asks you to convert into , the input is 1 km = ? mm.
Output Format
Output lines, the answers to all problems in order. When outputting, simply substitute the answer for the ? in the input, and output the rest of the string exactly unchanged. Since Xiaoyang's problems only convert a larger unit into a smaller unit, and the input is an integer, the answer is also guaranteed to be an integer.
For example, if the problem asks you to convert into , the input is 1 km = ? mm, and you should output 1 km = 1000000 mm.
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
Sample Explanation
For the first sample, the input contains two queries:
- The first line asks to convert kilometre into millimetres; by the conversion , so output
1 km = 1000000 mm. - The second line asks to convert metre into millimetres; , so output
1 m = 1000 mm.
The program only needs to replace the ? in each query with the corresponding result.
Constraints
- , and is an integer
- All unit conversions cover only the six types described (metre→millimetre, kilometre→millimetre, kilometre→metre, gram→milligram, kilogram→milligram, kilogram→gram), and unit1 is guaranteed to be larger than unit2
- The answer is guaranteed to fit in an integer and may be output directly