Game

아직 제출이 없습니다시간 제한8초메모리 제한512 MB

문제

Let us consider the following two-player game. Initially, there is some sequence of numbers. Then players in turns remove either the first or the last element of the sequence. If after some move, the sequence becomes one of several terminal sequences, then the game ends and the player who made the last move wins. If no player can make a move (because the sequence has length 00), then no player wins. Determine which player has a winning strategy in this game.

입력

The first line of input contains the number of test cases zz. The descriptions of the test cases follow.

The first line of each test case contains an integer nn (1n1061 \le n \le 10^6) followed by nn integers a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n (0a_i1090 \le a\_i \le 10^9), the initial sequence itself. The second line contains one integer kk, the number of terminal sequences. The next kk lines contain descriptions of terminal sequences. Each of these lines contains an integer mm (m1m \ge 1), the length of the sequence, followed by mm elements of the sequence: w_1,w_2,,w_mw\_1, w\_2, \ldots, w\_m (0w_i1090 \le w\_i \le 10^9). The total length of terminal sequences does not exceed 31063 \cdot 10^6.

Consecutive test cases will be separated by a single blank line.

출력

For each test case, print "FIRST" if the player who makes the first move wins, "SECOND" if the other player wins, or "DRAW" if no player wins.