Under construction

Still being built. Things may change

Artificial Intelligence?

Time limit1sMemory limit128 MB

Summary
Given a word problem stating two of power, voltage, and current with optional metric prefixes, compute the missing quantity using P = U * I.
Level

Easy3 of 10

Topics
String, Math, Implementation
Solved
No attempts yet

Problem

High school physics teachers often think that word problems are harder than pure calculations — after all, students first have to read and understand the problem.

So instead of stating a problem as "U=10V, I=5A, P=?", they phrase it like this: "You have an electrical circuit containing a battery with a voltage of U=10V and a light bulb. A current of I=5A flows through the bulb. What power is generated in the bulb?"

However, half of the students never pay attention to the text anyway. They simply pull the given values out of the text — U=10V, I=5A — and think: "Which formulas do I know? Ah yes, P=U⋅IP = U \cdot I. Therefore P=10 V⋅5 A=500 WP = 10\,\text{V} \cdot 5\,\text{A} = 500\,\text{W}. Done."

This does not always work, so these students are usually not the top scorers on physics tests — but the simple algorithm is generally good enough to pass the class.

Today we check whether a computer can pass a high school physics test. We focus on P-U-I problems: problems in which two of power, voltage, and current are given and the third is asked for.

Write a program that reads such a word problem and solves it using the simple algorithm above.

Input

The first line contains the number of test cases.

Each test case is a single line that contains exactly two data fields plus arbitrary extra words. A data field has the form I=xA, U=xV, or P=xW, where x is a real number. Directly before the unit (A, V, or W) one of the prefixes m (milli, 10−310^{-3}), k (kilo, 10310^{3}), or M (Mega, 10610^{6}) may appear. In summary, data fields follow this grammar:

DataField ::= Concept '=' RealNumber [Prefix] Unit
Concept   ::= 'P' | 'U' | 'I'
Prefix    ::= 'm' | 'k' | 'M'
Unit      ::= 'W' | 'V' | 'A'

Additional guarantees:

  • The equals sign ('=') never appears anywhere except inside a data field.
  • There is no whitespace (tabs or spaces) inside a data field.
  • Exactly one of the pairs (P and U), (P and I), or (U and I) is given.

Output

For each test case, print two lines:

  • a line reading "Problem #k", where k is the test case number (starting from 1);
  • a line giving the solution — voltage, power, or current, depending on which one was missing — written without any prefix and with exactly two decimal places.

Separate consecutive test cases with a blank line.

Examples1

  1. Example 1

    Input
    3
    If the voltage is U=200V and the current is I=4.5A, which power is generated?
    A light-bulb yields P=100W and the voltage is U=220V. Compute the current, please.
    bla bla bla lightning strike I=2A bla bla bla P=2.5MW bla bla voltage?
    
    Expected output
    Problem #1
    P=900.00W
    
    Problem #2
    I=0.45A
    
    Problem #3
    U=1250000.00V