This page is still under construction.

Parts of this page are still being built. What you see may change.

Butterfly Ballot

Time limit1sMemory limit256 MB

Summary
Decide whether the candidates can be ordered so candidate 1 finishes first when half of each ballot position's supporters spill to the next position.
Level

Medium5 of 10

Topics
Greedy, Sorting, Simulation
Solved
No attempts yet

Problem

A butterfly ballot lists the candidate names down one column and puts the check boxes in the other column. When the two columns are offset by half a row, telling which box belongs to which candidate is hard. On the ballot below it is easy to mark the box next to UCLA while meaning to vote for USC. The same thing happens in an election.

You design a ballot that puts your own candidate in first place. All nn candidates must appear on it, and you choose the order from top to bottom. The boxes go in the other column. The first box sits above the first candidate, the second box sits between the first and the second candidate, and the rest follow the same pattern.

Among the voters who intend to vote for the candidate in position ii from the top, half vote for that candidate and half mark the box of the candidate in position i+1i+1, one row below. Every voter who intends to vote for the candidate in the last position votes correctly.

Candidate 1 is your candidate. Decide whether an order exists that puts candidate 1 in first place. A tie for first place counts as a win.

Input

The first line contains the number of data sets KK, where K≥1K \ge 1.

KK data sets follow. The first line of a data set contains the number of candidates nn on the ballot, where 1≤n≤1001 \le n \le 100. Candidate 1 is the one you are trying to make win. Each of the next nn lines contains viv_i, the number of voters who intend to vote for candidate ii, where 1≤vi≤1061 \le v_i \le 10^6. Every viv_i is even, so it divides by 2 exactly.

Output

For each data set, print Data Set x: on a line of its own, where xx is the number of the data set. If candidate 1 can be made to finish first, print Possible on the next line, otherwise print Impossible. Print one blank line after each data set.

Examples4

  1. Example 1

    Input
    2
    5
    10
    60
    8
    94
    54
    5
    10
    60
    8
    94
    56
    
    Expected output
    Data Set 1:
    Possible
    
    Data Set 2:
    Impossible
    
  2. Example 2

    Input
    3
    1
    2
    2
    1000000
    2
    2
    2
    1000000
    
    Expected output
    Data Set 1:
    Possible
    
    Data Set 2:
    Possible
    
    Data Set 3:
    Possible
    
  3. Example 3

    Input
    4
    3
    28
    96
    336
    3
    2
    100
    100
    3
    86
    176
    938
    5
    4
    144
    1154
    222
    822
    
    Expected output
    Data Set 1:
    Possible
    
    Data Set 2:
    Impossible
    
    Data Set 3:
    Possible
    
    Data Set 4:
    Possible
    
  4. Example 4

    Input
    4
    5
    32
    204
    88
    224
    52
    5
    32
    206
    88
    224
    52
    4
    4
    194
    18
    162
    4
    4
    194
    20
    162
    
    Expected output
    Data Set 1:
    Possible
    
    Data Set 2:
    Impossible
    
    Data Set 3:
    Possible
    
    Data Set 4:
    Impossible