#K68417. Last Color Drawn
Last Color Drawn
Last Color Drawn
In this problem, you are given a square grid of size \(n \times n\) and a series of drawing operations. Each operation paints an entire row or column with a specific color. An operation is described by a type \(T\) (where \(T\) is either 'R' for a row or 'C' for a column), an index \(i\) (using 1-based indexing), and a color represented by a single uppercase letter.
Your task is to determine the color used in the final drawing operation of each test case.
Note: The drawing operations are applied in the order they appear in the input. The grid itself is only conceptual and does not affect the processing of the operations.
inputFormat
The input begins with an integer (T) indicating the number of test cases. For each test case, the first line contains two integers (n) and (k) representing the size of the grid and the number of drawing operations, respectively. This is followed by (k) lines, each containing a drawing operation in the format: a character (either 'R' or 'C'), an integer (i), and a character denoting the color.
outputFormat
For each test case, output a single line containing the color of the final drawing operation.## sample
3
3 4
R 1 A
C 2 B
R 3 C
C 3 D
5 5
R 1 X
R 2 Y
C 1 Z
C 5 W
R 5 V
2 2
C 1 M
R 2 N
D
V
N
</p>