#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: 1 km=1000 m=1000000 mm1\,\text{km} = 1000\,\text{m} = 1000000\,\text{mm}.
  • Weight units include kilogram (kg), gram (g), and milligram (mg), with relationships: 1 kg=1000 g=1000000 mg1\,\text{kg} = 1000\,\text{g} = 1000000\,\text{mg}.

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 NN, the number of problems.

The following NN lines each contain a string describing a conversion problem, in the format $x$ unit1 = ? unit2. Here xx is a non-negative integer not exceeding 10001000, 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 1 km1\,\text{km} into mm\text{mm}, the input is 1 km = ? mm.

Output Format

Output NN 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 xx is an integer, the answer is also guaranteed to be an integer.

For example, if the problem asks you to convert 1 km1\,\text{km} into mm\text{mm}, 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 11 kilometre into millimetres; by the conversion 1 km=1000000 mm1\,\text{km} = 1000000\,\text{mm}, so output 1 km = 1000000 mm.
  • The second line asks to convert 11 metre into millimetres; 1 m=1000 mm1\,\text{m} = 1000\,\text{mm}, so output 1 m = 1000 mm.

The program only needs to replace the ? in each query with the corresponding result.

Constraints

  • 1≤N≤10001 \le N \le 1000
  • 0≤x≤10000 \le x \le 1000, and xx 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