Under construction

Still being built. Things may change

Rank and File (Large)

Interview

Time limit5sMemory limit512 MB

Summary
Given all but one of the rows and columns of a sorted grid, find the missing list of heights in increasing order.
Level

Easy3 of 10

Topics
Implementation, Hash map, Sorting
Solved
No attempts yet

Problem

When Sergeant Argus's army assembles for drilling, the soldiers stand in the shape of an N×NN \times N square grid, with exactly one soldier in each cell. Each soldier has a certain height.

Argus believes that he must keep an eye on all of his soldiers at all times. Since he likes to look at the grid from the upper left, he requires that:

  • Within every row of the grid, the soldiers' heights are in strictly increasing order from left to right.
  • Within every column of the grid, the soldiers' heights are in strictly increasing order from top to bottom.

No two soldiers in the same row or column may have the same height, but several soldiers in the grid as a whole may have the same height.

Since soldiers sometimes train separately with their row or their column, Argus has asked you to make a report consisting of 2N2N lists of the soldiers' heights: one for each row (in left-to-right order) and one for each column (in top-to-bottom order). While surveying the soldiers you only had small pieces of paper, so you wrote each list on a separate piece. On the way back to your office, a loud bugle blast startled you, you dropped all the pieces, and the wind blew one away before you could recover it! The remaining pieces are now in no particular order, and you cannot remember which lists are rows and which are columns, since you did not write that down.

Argus will make you do hundreds of push-ups if you hand in an incomplete report. Find the missing list.

Input

The first line of the input gives the number of test cases, TT. TT test cases follow. Each consists of one line with an integer NN, followed by 2N−12N-1 lines of NN integers each: the lists you have, as described in the statement. It is guaranteed that these lists are all but one of the rows and columns of a grid that satisfies the conditions in the statement.

Limits

  • 1≤T≤501 \le T \le 50
  • 2≤N≤502 \le N \le 50
  • Every height is between 11 and 25002500, inclusive.
  • The integers on each line are in strictly increasing order.
  • It is guaranteed that a unique valid answer exists.

Output

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the NN integers of the missing list in strictly increasing order, separated by spaces.

Hint

In the sample case, the grid must be either this:

1 2 3
2 3 4
3 5 6

or this:

1 2 3
2 3 5
3 4 6

In either case, the missing list is 3 4 6.

Examples1

  1. Example 1

    Input
    1
    3
    1 2 3
    2 3 5
    3 5 6
    2 3 4
    1 2 3
    
    Expected output
    Case #1: 3 4 6