Filter & Perform#6371

Filter & Perform

10 seconds
64 megabytes
Medium

A data set in an input file contains several lines of data. The first line provides two pieces of information: the first is an integer between and (inclusive), which represents the number of subsequent lines in the data set, and the second is any of the following symbols \{+, -, ^\}, which represents the operation to be performed.

From the second line onwards, there is one data element per line, which can be a positive integer, a positive real number, or a string (with a maximum length of ).

A program is to be written so that if the symbol in the first line is , then only the lines containing integers in the data set will produce output. The output will be the sum of each digit in the integer data. On the other hand, if the symbol is , then only the lines containing strings will produce output. The output will be the string with all characters (if any) removed. If the symbol is ^, then only the lines containing real numbers will produce output.

The output will be the number in its exponential format. For example, will be represented as , will be , and will be 2.53e-1.

Input

The first line of the input data contains an integer which represents the number of test cases. This line is followed by the data for each of the test cases. Each test case begins with a line containing two data: an integer denoting the number of data lines (1 \leq n \leq 5), and a special symbol , , or ^ denoting the operation to be performed. Each data line in the data set contains either a positive integer, a positive real number, or a string with a maximum size of .

Output

The output comprises one line for each test case. The line begins with the prefix Case #x: where represents the case number, followed by the output of the test case. Depending on the symbol provided in the first line of the test case, only data of the applicable type will produce output, with a space in between.

Examples

Example 1

Loading
Loading