#0004E4

DSA-struja

Dario loves physics. His teacher is talking about resistors, voltage, ampere-meters etc. while Dario is wondering about voltage in a circuit scheme he's looking at. Alas, he needs your help.


There are only light-bulbs placed in the circuit he is looking at, and your task is to calculate voltage and power on first light-bulb in the circuit.


InputIn the first line there are two natural numbers N and M. M ( 1 < M < N < 1 000 ) is the number of different elements in the circuit.
In the next M lines there are symbols and resistances of the respective bulbs, separated by a space.
In the next N lines there are strings representing elements of the circuit. If more than one element is in the same row, then they are connected in parallel. Neighbouring rows are connected serially. (See picture below for clarification)

OutputOutput the power and voltage on the first light-blub, assuming that the voltage of the battery is 220V.

Input:
1 1
A 10
A

Output:
I-22 U-220


Input:
2 1
X 220
X
X

Output:
I-1 U-110


Input:
3 2
X 220
A 120
AA
X
X

Output:
I-1 U-26

If it is power lower then 0 then you just write 1
Example for 3 test example :
Image: dsadsa

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.