#K38607. Final Grid Generation

    ID: 26236 Type: Default 1000ms 256MiB

Final Grid Generation

Final Grid Generation

You are given an (N \times N) grid initially filled with white cells. You have to perform (M) operations on this grid. Each operation is represented by a triplet ((x, y, c)), where (x) and (y) are the 1-indexed coordinates of a cell, and (c) is the color indicator: (1) means the cell should be colored black (denoted by 'B') and (0) means it should be white (denoted by 'W'). After processing all operations sequentially, output the final grid where each row is printed as a single string without spaces.

inputFormat

The input is provided via stdin. The first line contains an integer (T), denoting the number of test cases. For each test case, the first line contains an integer (N) (the size of the grid), followed by an integer (M) (the number of operations). The next (M) lines each contain three integers: (x), (y), and (c). Each test case should be processed independently.

outputFormat

For each test case, output the final grid to stdout. The grid should be printed as (N) lines, with each line being a concatenation of the characters representing that row (with no spaces between characters).## sample

1
3
4
1 1 1
2 2 1
3 3 1
1 1 0
WWW

WBW WWB

</p>