Under construction

Still being built. Things may change

River Game

Time limit0.5sMemory limit512 MB

Summary
Two players alternately place cameras on firm ground squares next to wet zones under adjacency limits; the task is to decide who wins with optimal play.
Level

Medium7 of 10

Topics
Game theory, Graph, Combinatorics
Solved
No attempts yet

Statement

Together with an ornithologist friend, you spend hours bird-watching in wetlands, waiting for a rare bird that you want to photograph.

To pass the time, you devised a small game. The wetland is an N×NN \times N grid made of three types of squares: firm ground, wet zone, and protected zone.

Connected wet zone squares form wet areas. A wet area is a maximal set of wet zone squares such that any square of the area can reach any other square of the area through a path of connected wet zone squares. Two squares are connected when they share an edge, so a square not on the border of the grid is connected to 4 other squares. Each wet area must be connected to both the left and right sides of the grid, and it contains no more than 2N2N wet zone squares. Wet zone squares that belong to two different wet areas are always at distance at least 3 from each other, where distance is counted by moving horizontally or vertically on the grid. For example, in the two examples below, the blue squares are at distance 3 from one another.

You and your friend take turns placing a camera on the wetland under these rules:

  • The camera must be on a firm ground square.
  • The camera must be adjacent to a wet zone square, so that you can take bird photos.
  • The camera must not be on a protected zone square.
  • There cannot be two cameras on the same square.
  • Two cameras adjacent to the same wet area cannot be adjacent to each other. Adjacency means sharing an edge.

The first player who cannot place a camera anymore loses the game.

Assuming both players play optimally, will the first player win or lose?

Input

The input consists of the following lines:

  • on the first line, the integer NN;
  • on the next NN lines, a string representing a row of the grid: \* represents a wet zone square, . represents a firm ground square, and x represents a protected square.

Output

Print First player will win if the first player wins the game when both players play optimally, or Second player will win otherwise.

Constraints

The input satisfies 1≤N≤101 \le N \le 10.

Examples2

  1. Example 1

    Input
    3
    ...
    ...
    ***
    
    Expected output
    First player will win
    
  2. Example 2

    Input
    10
    **********
    *.x.*.....
    *...*.....
    *****.....
    ..........
    ..........
    xx******..
    ***x...*..
    ..*...x*.x
    ..********
    
    Expected output
    Second player will win