Hide

Problem H
Who wins?

Languages en sv

Johan and Abdullah are playing tic-tac-toe, but they are having a hard time figuring out who won. To win in tic-tac-toe you need to have three of your letter in a row, either vertically, horizontally, or diagonally. Johan uses the letter X and makes the first move, and Abdullah uses the letter O. Help them figure out who has won, if anyone.

Input

Input consists of a valid tic-tac-toe position, where an underscore _ represents an empty square, and the letters X and O represent Johan’s and Abdullah’s moves. The position is described by three rows, each containing three space-separated characters each. It is guaranteed that at most one player has won.

Output

Print the winner of the game. First print the name, “Johan”, “Abdullah” or “ingen”, then “har vunnit”.

Grading

Your solution will be tested on a number of test-case groups. To receive points for a group, your solution must correctly solve every test-case in the group.

Group

Point value

Restrictions

$1$

$20$

No player has three letters in a row along a diagonal

$2$

$40$

Abdullah is not the winner of any game

$3$

$40$

No further restrictions

Sample Input 1 Sample Output 1
_ _ _
X O _
X X O
ingen har vunnit
Sample Input 2 Sample Output 2
_ X _
O X _
O X O
Johan har vunnit
Sample Input 3 Sample Output 3
_ _ O
_ O X
O X X
Abdullah har vunnit

Please log in to submit a solution to this problem

Log in