#P2575. Divine Checkers Showdown

    ID: 15844 Type: Default 1000ms 256MiB

Divine Checkers Showdown

Divine Checkers Showdown

After growing tired of video games, AKN decides to challenge his friend wwx to a game of checkers – a game played with mystical strategies by ancient deities. The game is played on an \(n \times 20\) board with several pieces placed on it. Both players play optimally, and AKN moves first. Given the initial board configuration, determine who wins the game.

Game Rules:

  • For any piece placed in a cell, if the cell immediately to its right is empty, the only legal move is to move the piece one cell to the right.
  • If the cell immediately to the right is occupied, then the piece jumps to the first empty cell to its right (i.e. scanning from left to right, skip all consecutive occupied cells until the first empty cell is found). If there is no empty cell to the right, the piece cannot be moved.
  • If no piece on the board can be moved according to the above rules, the player whose turn it is loses the game.

The board is given row by row; note that moves in different rows do not affect each other. The overall game is the disjunctive sum of the games in each row.

Your task is to determine, with both players using their best strategy, whether akn (the first player) wins or wwx (the second player) wins.

inputFormat

The first line contains a single integer \(n\) (the number of rows, \(1 \leq n \leq \text{some limit}\)). Each of the following \(n\) lines contains a string of length 20 consisting of characters '0' and '1'. Here, '1' indicates a cell with a piece and '0' indicates an empty cell. The board is 1-indexed from left to right.

outputFormat

Output a single line containing akn if the first player wins the game under optimal play, or wwx otherwise.

sample

1
10000000000000000000
akn

</p>