Horse Racing

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 3993
64-bit integer IO format: %I64d      Java class name: Main

Description

Tian Ji likes horse racing. Once, he and QI Wei Wang agreement, to carry out a game they discuss the good, to their horses into the upper, middle and lower third-class.

Due to individual differences, each horse's speed is unique. They started this game, the upper to the upper, middle to middle, lower to lower. Qi Wei Wang’s horses are better than Tian Ji's horses. So Tian Ji always lost. Sun Bing Tian Ji's friends gave him an idea. He let lower to upper, upper to middle, middle to lower, as you know. Then Tian Ji won.
Now Tian Ji and Qi Wei Wang host the game again, they all have n horse. As Qi Wei Wang is rich he will give some money to Tian Ji. When Qi Wei Wang lost he give 3 RMB to Tian Ji, when it is tie Qi Wei Wang gives Tian Ji 1 RMB, Of course if Tian Ji loses he would not get any money from Qi Wei Wang.
Every round Tian Ji chooses a horse first, and then Qi Wei Wang chooses a horse haven’t been chosen by random. Tian Ji want you to tell him the Expectation of money he can get. Because Tian Ji has a friend named Sun Bing so he will use the best way to choose horses.

Input

The first line is an integer t (<=10) indicating the case number. For each case there are three lines, the first line is an integer n (<12) indicating the number of the horses. The next two lines each have n numbers, the first line is the speed of the Qi Wei Wang’s horses, and the second is Tian Ji’s

Output

For each case output a line. Only a number of expectation. 6 decimal places reserved

Sample Input

2
2
1 2
3 4
2
1 4
2 3

Sample Output

6.000000
3.000000

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .