H. Sortable Grid
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a binary grid of size $$$N \times M$$$ (containing only '0's and '1's). You have a special ability: for any column, you can swap any two elements within that column. This means you can arrange the '0's and '1's in any column in any order you like, but you cannot move elements between different columns.

A grid is considered row-sorted if every row is sorted in non-decreasing order (i.e., all '0's appear before all '1's).

You will be given $$$Q$$$ queries. Each query consists of a cell $$$(r, c)$$$. For each query, you must first flip the value in cell $$$(r, c)$$$ of the current grid (a '0' becomes a '1', and a '1' becomes a '0'). This change is permanent and carries over to subsequent queries. After each flip, you must determine if the resulting grid can be made row-sorted using your column-swapping ability.

Input

Each test consists of multiple test cases. The first line contains a single integer $$$T$$$ $$$(1 \le T \le 10^5)$$$ — the number of test cases. The description of the test cases follows.

The first line of each test case contains integers $$$N, M,$$$ and $$$Q$$$ ($$$1 \le N, M$$$, $$$1 \le N \times M \le 10^5$$$, $$$1 \le Q \le 10^5$$$).

The next $$$N$$$ lines of each testcase each contain a string of $$$M$$$ characters ('0' or '1'), representing the initial grid.

The next $$$Q$$$ lines each contain two integers $$$r$$$ and $$$c$$$ ($$$1 \le r \le N$$$, $$$1 \le c \le M$$$), representi ng the coordinates of the cell to flip for that query. It's guaranteed that sum of N * M overall testcases doesn't exceed $$$10^5$$$ and sum of Q doesn't exceed $$$10^5$$$

Output

For each testcase, For each of the $$$Q$$$ queries, print Yes on a new line if the grid can be made row-sorted after the flip, and No otherwise.

Example
Input
5
5 2 3
11
11
01
00
11
3 1
4 2
4 1
3 7 2
0101001
0111111
1011100
1 4
1 6
2 2 4
11
01
2 2
2 1
1 1
1 1
3 4 1
1110
1110
1100
3 3
1 1 2
0
1 1
1 1
Output
Yes
Yes
Yes
No
Yes
Yes
No
Yes
No
No
Yes
Yes