


n = 5, moves = {{0,2}, {0,0}, {1,1}, {2,2}, {2,0}}

1. The array ‘moves’ doesn’t contain any repeating positions, and all positions are valid.
2. The array ‘moves’ follows all the rules of tic-tac-toe.
3. You do not need to print anything; it has already been taken care of. Just implement the function
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains an integer ‘N’ denoting the size of the array ‘moves’.
The next ‘N’ lines of each test case contain two space-separated integers denoting a tuple of the array ‘moves’.
For each test case, if there is a winner, print their name, i.e., ‘player1’ or ‘player2’. Otherwise, depending on the grid’s final state, print ‘uncertain’ or ‘draw’ (without quotes).
1 <= T <= 1000
1 <= N <= 9
| moves[i] | = 2
0 <= moves[i][j] <= 2
Where ‘moves[i][j]’ represents elements in the array ‘moves’.
Time limit: 1 second
Create a 2-D array ‘grid’ of size ‘3 x 3’ with each element set to 0. Use this array ‘grid’ to store the state of the actual grid. We know that ‘player1’ makes all the even moves (0-based indexing), and ‘player2’ makes all the odd moves because ‘player1’ always plays first, and the players take alternate turns. For a move by ‘player1’, mark the ‘grid’ position as 1. For a move by ‘player2’, mark the ‘grid’ position as 4. Check if any row, column, or diagonal has three same characters and return the appropriate answer.
We don’t need to simulate the actual grid state. The sums of each row, column, and diagonal of the grid are enough to decide the winner. After each move, modify the sums of the corresponding row, column, and diagonal. For ‘player1’, increase the sum by 1, and for ‘player2’, increase the sum by 4. If any of the computed sums is 3, ‘player1’ wins, and if it is 16, ‘player2’ wins.