Unit Conversion

Given x of unit A equals y of unit B, convert each listed amount to the other unit and print the result to six decimals.

Easy2MathImplementationNo attempts yetTime limit2sMemory limit512 MB

Problem

"How do you say 'two kilos' in English?" Dudu asked that in 2015.

Dudu always has trouble with measurements and unit conversions. Do the conversions for him.

There are two units, A and B. An amount of xx in unit A equals an amount of yy in unit B. If A is kilograms and B is pounds, then x=3.25x = 3.25 and y=7.165024y = 7.165024 is one example.

Use that relation to convert each given amount into the other unit.

Input

The first line has two real numbers xx and yy, separated by a space. It means that xx of unit A equals yy of unit B.

The second line has the number of conversions NN.

Each of the next NN lines has an amount zz and a unit qq, separated by a space. qq is the uppercase letter A or B. If qq is A, convert zz of unit A into unit B. If qq is B, convert zz of unit B into unit A.

Output

Print NN lines, one conversion result per line, in input order. Round each value to six decimal places and print exactly six digits after the decimal point. A result of zero is printed as 0.000000.

Constraints

  • 1N1000001 \le N \le 100\,000
  • 0.001x10000.001 \le x \le 1000, 0.001y10000.001 \le y \le 1000
  • 0z10000000 \le z \le 1000000
  • xx, yy, and zz have at most six digits after the decimal point.
  • Every conversion result is at most 10000001000000.
  • No answer lands on a rounding boundary at the seventh decimal place, so double precision arithmetic is enough.