# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

# Game of Tic-Tac-Toe

By · Limits 1s, 512 MB

Alice and Bob is a playing a game of tic-tac-toe, to be precise a variant of tic-tac-toe called Notakto. In a game of Notakto, there will always be a winner.

Notakto is played on 3×3 tic-tac-toe board with both players playing X. A game ends when the board contains three consecutive X, at which point the player to have made the last move loses the game.

Given a configuration of the board, you have to find out the winner. Alice always makes the first move.

## Input

You are given an integer n (0 < n < 200), number of games.

For each game, you are given a 3×3 grid, each grid cell is empty (denoted by dot), or occupied by a cross (denoted by X).

## Output

For each game, print the winner of that game, in the format "Game #x: winner". Here, x is the game number.

## Samples

InputOutput
1
.X.
.X.
..X
Game #1: Bob

InputOutput
2
.X.
.XX
X.X
...
.XX
...
Game #1: Bob
Game #2: Alice

### Statistics

27% Solution Ratio

ZeronfinityEarliest, May '18

CLown1331Fastest, 0.0s

ZeronfinityLightest, 131 kB

CLown1331Shortest, 1389B