#K55127. Grid Light Bulb Manipulation

    ID: 29907 Type: Default 1000ms 256MiB

Grid Light Bulb Manipulation

Grid Light Bulb Manipulation

You are given a grid where each cell can have a light bulb that is initially off. You will receive a sequence of commands, each in one of the following formats: (L\ x\ y), (T\ x\ y), or (Q\ x\ y). Here, (L) turns on the light bulb at position ((x, y)); (T) toggles the bulb at ((x, y)) (if it is on, it becomes off, and vice versa); and (Q) queries the current state of the bulb at that position. Process all commands in order and output the result of each query command.

inputFormat

The first line contains an integer (n) (the number of commands). Each of the following (n) lines contains a command in one of the following forms: (L\ x\ y), (T\ x\ y), or (Q\ x\ y), where (x) and (y) are integers.

outputFormat

For every query command (Q\ x\ y), output a single line with either (ON) if the light bulb at ((x, y)) is on, or (OFF) if it is off.## sample

6
L 1 2
Q 1 2
T 1 2
Q 1 2
L 3 4
Q 3 4
ON

OFF ON

</p>