Filter and Perform

No attempts yetTime limit1sMemory limit128 MB

Problem

Each data set spans several lines. The first line holds two values. The first is an integer nn between 1 and 5 that says how many data lines follow. The second is one of +, -, ^ and says which operation to perform. Each of the next nn lines holds one data element, which is a positive integer, a positive real number, or a string of length at most 10.

Classify a data element by these rules.

  • An element made only of digits is an integer.
  • An element made of one or more digits, a single decimal point, then one or more digits is a real number.
  • Everything else is a string. For example 1a, 12.34.56, .5, and 5. are strings.

When the symbol is +, only integer elements produce a result. Print the sum of the digits of that integer.

When the symbol is -, only string elements produce a result. Print the string with every lowercase a deleted. An uppercase A stays.

When the symbol is ^, only real elements produce a result. Print that number in exponential form, built like this. Drop the decimal point, then strip leading and trailing zeros from the digit string to get the significant digits d1d2dkd_1 d_2 \dots d_k, so the original value equals d1.d2dk×10ed_1.d_2 \dots d_k \times 10^e. Write d1d_1 when kk is 1 and d1.d2dkd_1.d_2 \dots d_k otherwise, then e, then the exponent ee. A negative exponent carries a leading -, and a positive one carries no +. So 2.53 becomes 2.53e0, 25.3 becomes 2.53e1, 0.253 becomes 2.53e-1, and 1.000 becomes 1e0.

Input

The first line contains the number of test cases TT. The data for each test case follows.

The first line of a test case contains the number of data lines nn (1n51 \le n \le 5) and one of the symbols +, -, ^, separated by a space. Each of the next nn lines contains a positive integer, a positive real number, or a string of length at most 10. No data element contains whitespace.

Output

Print one line per test case. The line starts with Case #x:, where xx is the test case number counting from 1. After the prefix, print the results from the elements of the type the symbol selects, in input order, separated by one space, with one space between the prefix and the first result.

If no element is of that type, print the prefix alone with no trailing space. An empty result still holds its place, so the separating spaces around it are printed as usual.