Deceitful War (Small)

Given both players' block weights, compute Naomi's best scores under honest War rules and under optimal lying in Deceitful War.

Medium6GreedySortingGame theoryNo attempts yetTime limit5sMemory limit512 MB

Problem

Naomi and Ken each have NN identical looking wooden blocks. Every block weighs more than 0.0kg and less than 1.0kg, and all 2N2N weights are different.

They play a game called War with the following rules.

  1. Each player weighs all of their own blocks. A player knows the weights of their own blocks and nothing about the other player's blocks.
  2. Repeat the following NN times.
    1. Naomi picks one of her own blocks. Call its mass ChosenNaomi.
    2. Naomi tells Ken the value of ChosenNaomi.
    3. Ken picks one of his own blocks. Call its mass ChosenKen.
    4. They put the two blocks on opposite pans of a balance scale, and whoever played the heavier block gets one point.
    5. Both blocks burn up.

Ken has exactly one strategy that maximizes his own score without assuming anything about Naomi's strategy, and he always follows it.

Naomi decides to play a different game called Deceitful War instead. Ken still believes he is playing War. Two rules change.

  1. Naomi has already weighed Ken's blocks while he was not looking. Naomi knows all 2N2N weights, and Ken knows only his own.
  2. Instead of announcing the mass of the block she picked, Naomi announces some number ToldNaomi greater than 0.0kg and less than 1.0kg. Ken takes that number to be ChosenNaomi.

The scale must never expose the lie, so in every round Naomi has to satisfy both of these conditions.

  • ChosenNaomi > ChosenKen holds if and only if ToldNaomi > ChosenKen holds.
  • ToldNaomi is not equal to the mass of any block Ken holds, because Ken knows that no two blocks weigh the same.

Naomi knows what Ken knows and knows the optimal War strategy Ken follows, so she always predicts the block Ken will play.

You are given the masses of the blocks the two players start with. Find the score Naomi gets when she plays Deceitful War optimally, and the score she gets when she plays War optimally instead. In both cases Ken believes the two are playing War and maximizes his own score.

Two situations, for illustration.

One block is left on each side, Naomi holds 0.5kg and Ken holds 0.6kg. Ken takes the point. If Naomi announced 0.6kg or more, the scale would tip toward Ken and he would catch the lie.

Two blocks are left on each side, Naomi holds 0.7kg and 0.2kg while Ken holds 0.8kg and 0.3kg. Naomi can play her 0.2kg block and claim she picked a 0.6kg one. Ken believes her, plays his 0.8kg block and scores a point. The scale tips toward Ken exactly as he expects, so he never learns that he was deceived. In the next round Naomi plays her 0.7kg block, truthfully says 0.7kg, and scores a point. Had she played War, Ken would have scored two points and Naomi none.

Input

The first line contains the number of test cases TT. The first line of each test case contains NN, the number of blocks each player has. The next line contains the masses of Naomi's NN blocks separated by spaces, and the last line contains the masses of Ken's NN blocks in the same format.

Every mass is written as a 0, then a decimal point, then 1 to 5 digits. Ken and Naomi do not know that the numbers in the input have at most 5 digits after the decimal point, so Naomi may claim she played a block of 0.5000001kg and Ken has no reason to doubt her.

  • 1T501 \le T \le 50
  • 1N101 \le N \le 10
  • All 2N2N masses given to the two players are different, greater than 0.0 and less than 1.0.

Output

For each test case, print one line in the form Case #x: y z. Here xx is the test case number starting from 1, yy is the score Naomi gets when she plays Deceitful War optimally, and zz is the score she gets when she plays War optimally.