I am not getting expected output plese help

Tic-tac-toe is a game played between two players on a 3×3 grid. In a turn, a player chooses an empty cell and places their symbol on the cell. The players take alternating turns, where the player with the first turn uses the symbol X and the other player uses the symbol O. The game continues until there is a row, column, or diagonal containing three of the same symbol (X or O), and the player with that token is declared the winner. Otherwise if every cell of the grid contains a symbol and nobody won, then the game ends and it is considered a draw.

You are given a tic-tac-toe board A after a certain number of moves, consisting of symbols O, X, and underscore(_). Underscore signifies an empty cell.

Print

1: if the position is reachable, and the game has drawn or one of the players won.
2: if the position is reachable, and the game will continue for at least one more move.
3: if the position is not reachable.
Input
The first line contains an integer T, the number of test cases. Then the test cases follow.
Each test case contains 3 lines of input where each line contains a string describing the state of the game in ith row.
Output
For each test case, output in a single line 1, 2 or 3 as described in the problem.

Constraints
1≤T≤39
Aij∈{X,O,_}
Subtasks
Subtask #1 (100 points): Original Constraints

Sample Input
3
XOX
XXO
O_O
XXX
OOO


XOX
OX_
XO_
Sample Output
2
3
1
Explanation
Test Case 1: The board is reachable, and although no player can win from this position, still the game continues.

Test Case 2: There can’t be multiple winners in the game.

Test Case 3: The first player is clearly a winner with one of the diagonals.

Code:-
import java.util.Scanner;

public class TicTacToe {

public static void main(String[] args) {
	try (Scanner scan = new Scanner(System.in)) {
		int testCases = scan.nextInt();
		for (; testCases != 0;testCases-=1) {
			int cx = 0;
			int co = 0;
			int c_ = 0;
			char[][] arr = new char[3][3];
			for (int row = 0; row < 3; row++) {
				for (int col = 0; col < 3; col++) {
					arr[row][col] = scan.next().charAt(0);
					if (arr[row][col] == 'X')
						cx+=1;
					if (arr[row][col] == 'O')
						co+=1;
					if (arr[row][col] == ' ')
						c_+=1;
				}
			}
			int x = 0;
			int o = 0;
			if (arr[0][0] == 'X' && arr[1][0] == 'X' && arr[2][0] == 'X')
				x = 1;
			if (arr[0][1] == 'X' && arr[1][1] == 'X' && arr[2][1] == 'X')
				x = 1;
			if (arr[0][2] == 'X' && arr[1][2] == 'X' && arr[2][2] == 'X')
				x = 1;
			if (arr[0][0] == 'X' && arr[1][1] == 'X' && arr[2][2] == 'X')
				x = 1;
			if (arr[0][0] == 'X' && arr[0][1] == 'X' && arr[0][2] == 'X')
				x = 1;
			if (arr[1][0] == 'X' && arr[1][1] == 'X' && arr[1][2] == 'X')
				x = 1;
			if (arr[2][0] == 'X' && arr[2][1] == 'X' && arr[2][2] == 'X')
				x = 1;
			if (arr[0][2] == 'X' && arr[1][1] == 'X' && arr[2][0] == 'X')
				x = 1;

			if (arr[0][0] == 'O' && arr[1][0] == 'O' && arr[2][0] == 'O')
				o = 1;
			if (arr[0][1] == 'O' && arr[1][1] == 'O' && arr[2][1] == 'O')
				o = 1;
			if (arr[0][2] == 'O' && arr[1][2] == 'O' && arr[2][2] == 'O')
				o = 1;
			if (arr[0][0] == 'O' && arr[1][1] == 'O' && arr[2][2] == 'O')
				o = 1;
			if (arr[0][0] == 'O' && arr[0][1] == 'O' && arr[0][2] == 'O')
				o = 1;
			if (arr[1][0] == 'O' && arr[1][1] == 'O' && arr[1][2] == 'O')
				o = 1;
			if (arr[2][0] == 'O' && arr[2][1] == 'O' && arr[2][2] == 'O')
				o = 1;
			if (arr[0][2] == 'O' && arr[1][1] == 'O' && arr[2][0] == 'O')
				o = 1;
			if (x == 1 && o == 1)
				System.out.println(3);
			else if (cx - co < 0)
				System.out.println(3);
			else if (cx - co > 1)
				System.out.println(3);
			else if (cx == 0 && co == 0 && c_ == 9)
				System.out.println(2);
			else if (x == 1 && o == 0 && cx > co)
				System.out.println(1);
			else if (x == 0 && o == 1 && cx == co)
				System.out.println(1);
			else if (x == 0 && o == 0 && c_ == 0)
				System.out.println(1);
			else if (x == 0 && o == 0 && c_ > 0)
				System.out.println(2);
			else
				System.out.println(3);
		}
	}
}

}