Problem J
Thermostat Trouble

Earth has recently been visited by aliens, and is now a member of a galactic federation consisting of many other advanced lifeforms on numerous habitable planets. This federation is very impressive in its scope and accomplishments, but unfortunately the usual failures of bureaucracy have become evident as the federation has failed to adopt a universal system of units. In particular, the units used to represent temperature vary drastically from world to world, which causes endless headaches for the galactic tourism industry.
A major problem occurs whenever an individual from one planet visits another planet and needs to adjust a hotel room thermostat, as most species are unable to perform the mental calculations necessary to determine the appropriate thermostat setting in unfamiliar units. You are an intern at Hubble Optimal Temperatures (H.O.T.), an Earth-based galactic startup company, and it is your job to write the backend code for an app that allows individuals to convert temperatures from any unit system to any other unit system. (Fortunately, other employees with more extensive training in LCI (Lifeform-Computer Interaction) are responsible for designing the interface.)
At the beginning of your project you are given a large file
containing temperature conversion information for every unit
system in the galaxy. Specifically, for each unit system
The unit systems in your input file are indexed
Input
The first line of input contains two space-separated
integers,
The next
Each of the next
Output
For each query output a line containing the temperature
value
Sample Input 1 | Sample Output 1 |
---|---|
3 6 0 100 32 212 88 7 1 2 15 1 2 -40 1 2 21 2 1 80 2 1 90 2 3 252 |
59/1 -40/1 349/5 80/3 290/9 -11/1 |