Splitting Pairs

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

문제

Alice and Bob are playing a modified game of Nim. Initially, there are some non-empty piles of stones in front of them. They take turns, and Alice takes the first turn.

On a single turn, a player must do the following actions in order:

  • Remove some number of piles of stones --- at least one but no more than half the number of piles.
  • Choose the same number of piles of remaining stones, and split each of those piles into two non-empty piles.

Notice that after each valid move, there should be the same number of non-empty piles of stones as at the start of the game. A player who cannot perform all the actions on their turn loses the game.

You are given many games, and for each one, you'd like to determine who would win if both players play optimally.

입력

The first line of input contains an integer tt (1t1,0001 \leq t \leq 1\\,000), which is the number of games Alice and Bob play.

Each game is represented on two lines. The first line of each game contains an integer nn (2n502 \leq n \leq 50), which is the number of piles of stones.

The next line of the game contains nn space-separated integers ss (1s10121 \leq s \leq 10^{12}), which are the number of stones in each pile.

출력

Output tt lines. For each game, output a single line with a single integer, which is 11 if Alice wins and 00 if Bob wins. Assume Alice takes the first turn, and both players play optimally. Output the game results in the order the games appear in the input.