When gathering test data for engineering analysis, simply collecting the raw sensor data from instruments is only half the job. one must take this data and apply calibration and conversion coefficients to translate sensor data to engineering units. Because many sensors are subject to wear and tear, their behavior changes over time and they require recalibration. Thus, test data for the same instrument recorded at the beginning of lengthy test program may require different conversions throughout the duration of the program. Your team is to write a utility to assist engineers in choosing the appropriate calibrations for a given set of test data.

The engineers that you are assisting identify their tests and calibration events wit ha number called the effectivity. Tests are numbered sequentially in increments of 100. Raw data measurements are termed parameters, and each parameter is identified wit ha name.

For example the first test is 100, the second test is 200, etc. The increment of 100 permits identification of intermediate steps (in particular, calibration measurements). after the first test, a set of calibrations is performed on one day. The following week, another set of calibrations is performed, then several days later a second test is taken. The timeline for these events may be viewed as:
EffectivityAction
100Test 1, collect data for parameters X and Y
101Calibrate parameters X and Y
102Calibrate parameters X and Z
200Test 2, collect data for parameters X, Y, and Z
For test 1, data is available for parameters X and Y, but no calibration is available. For est 2, the effectivity of parameters X and Z is 102, while the effectivity for parameter Y is 101. Knowing this information, an engineer can obtain data for test 2, then apply the appropriate calibrations and conversions to analyze the data.

Input

Your program does not have to keep track of the actual calibration data, only the effectivities of individual parameters. Input consists of a sequential list of events, which are either tests (T), calibrations (C) or data requests (R). Tests consist of the effectivity of the test (always a multiple of 100), and the parameters measured. Calibrations consist of the effectivity of the calibration and the parameters whose sensors were calibrated. Requests consists of the effectivity of the test for which data is requested and the parameters requested. Note that due to human error, calibrations may be back-dated (retroactive) to a previous effectivity. An effectivity will be specified only once.

The events have either a 'T', 'R', or 'C' in the first column, a single space, an effectivity, a single space, and one or more parameters, each separated by exactly one space. Parameter names are always upper case letters, 'A' through 'Z'. Effectivities are always decimal integers without leading zeros. There will never be more than 100 tests. It is impossible to have a zeroth test. It is impossible to represent more than 99 calibrations before or after tests.

Output

For each data request, report the effectivity of teach requested parameter known at the time of the request. When the parameters are present but uncalibrated, display an effectivity of 0. When a requested parameter is not present on a test, do not display the parameter. Each request should echo the letter 'R', a single space, the effectivity without any leading zeros, and zero or more parameters accompanied by their effectivities. For each parameter that has test data, print a space, the parameter name, an open parenthesis, the effectivity, and a close parenthesis. Display parameters in the order specified on the input.

Sample input
Sample output