QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 256 MB Puntuación total: 100

#5024. [Template] Deque

Estadísticas

Given $n$ non-negative integers $a_1, a_2, \cdots, a_n$.

Magic and Spark play a game. They take turns, and in each turn, a player can remove a number from either the leftmost or the rightmost end of the array. The player with the larger XOR sum of the numbers they have collected wins.

Determine who will win assuming both players play optimally. Output First if the first player wins, Second if the second player wins, and Draw if it is a draw.

Input

The first line contains a positive integer $T$, representing the number of test cases.

For each test case: The first line contains an integer $n$, the length of $a$. The next line contains $n$ integers $a_1, a_2, \cdots, a_n$, representing the sequence $a$.

Output

For each test case, output a single string representing the result.

Examples

Input 1

3
2
3 3
2
3 5
3
4 4 4

Output 1

Draw
First
Second

Subtasks

For $100\%$ of the data, $1 \leq T \leq 40$, $1 \le n \le 5 \times 10^4$, $0 \le a_i < 2^{31}$.

  • Subtask #1 (15 points): $n \le 15$.
  • Subtask #2 (20 points): $n \le 10^3$.
  • Subtask #3 (25 points): Each $a_i$ is guaranteed to be uniformly random in the range $[0, 2^{31}-1]$.
  • Subtask #4 (40 points): No special restrictions.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.