|Codeforces Round #206 (Div. 1)|
Given an n × n table T consisting of lowercase English letters. We'll consider some string s good if the table contains a correct path corresponding to the given string. In other words, good strings are all strings we can obtain by moving from the left upper cell of the table only to the right and down. Here's the formal definition of correct paths:
Consider rows of the table are numbered from 1 to n from top to bottom, and columns of the table are numbered from 1 to n from left to the right. Cell (r, c) is a cell of table T on the r-th row and in the c-th column. This cell corresponds to letter T r, c.
A path of length k is a sequence of table cells [(r 1, c 1), (r 2, c 2), ..., (r k, c k)]. The following paths are correct:
We should assume that a path [(r 1, c 1), (r 2, c 2), ..., (r k, c k)] corresponds to a string of length k: T r 1, c 1 + T r 2, c 2 + ... + T r k, c k.
Two players play the following game: initially they have an empty string. Then the players take turns to add a letter to the end of the string. After each move (adding a new letter) the resulting string must be good. The game ends after 2n - 1 turns. A player wins by the following scenario:
Your task is to determine the result of the game provided that both players played optimally well.
The first line contains a single number n (1 ≤ n ≤ 20).
Next n lines contain n lowercase English letters each — table T.
In a single line print string "FIRST", if the first player wins, "SECOND", if the second player wins and "DRAW", if the game ends with a draw.
Consider the first sample:
Good strings are strings: a, ab, ac, abd, acd.
The first player moves first and adds letter a to the string, as there is only one good string of length 1. Then the second player can add b or c and the game will end with strings abd or acd, correspondingly. In the first case it will be a draw (the string has one a and one b), in the second case the first player wins. Naturally, in this case the second player prefers to choose letter b and end the game with a draw.
Consider the second sample:
Good strings are: x, xa, xay.
We can see that the game will end with string xay and the first player wins.