# How to simplify this Tic Tac Toe program ?

number = 3 matrix = [] for i in range(number): string = input().split() matrix.append(string) if (matrix[0][0] == "O" and matrix[0][1] == "O" and matrix[0][2] == "O") or (matrix[1][0] == "O" and matrix[1][1] == "O" and matrix[1][2] == "O") or (matrix[2][0] == "O" and matrix[2][1] == "O" and matrix[2][2]) == "O": print("Abhinav Wins") elif (matrix[0][0] == "X" and matrix[0][1] == "X" and matrix[0][2] == "X") or (matrix[1][0] == "X" and matrix[1][1] == "X" and matrix[1][2] == "X") or (matrix[2][0] == "X" and matrix[2][1] == "X" and matrix[2][2]) == "X": print("Anjali Wins") elif (matrix[0][0] == "O" and matrix[1][0] == "O" and matrix[2][0] == "O") or (matrix[0][1] == "O" and matrix[1][1] == "O" and matrix[2][1] == "O") or (matrix[0][2] == "O" and matrix[1][2] == "O" and matrix[2][2] == "O"): print("Abhinav Wins") elif (matrix[0][0] == "X" and matrix[1][0] == "X" and matrix[2][0] == "X") or (matrix[0][1] == "X" and matrix[1][1] == "X" and matrix[2][1] == "X") or (matrix[0][2] == "X" and matrix[1][2] == "X" and matrix[2][2] == "X"): print("Anjali Wins") elif (matrix[0][0] == "O" and matrix[1][1] == "O" and matrix[2][2] == "O") or (matrix[0][2] == "O" and matrix[1][1] and matrix[2][0]) == "O": print("Abhinav Wins") elif (matrix[0][0] == "X" and matrix[1][1] == "X" and matrix[2][2] == "X") or (matrix[0][2] == "X" and matrix[1][1] and matrix[2][0]) == "X": print("Anjali Wins") else: print("Tie")