#Lutece0321. Milk And Bread
Milk And Bread
Migrated from Lutece 321 Milk And Bread
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
XiaoA and XiaoB are eating breakfast and they are brothers. Strangely, XiaoA has only some kinds of milk while XiaoB has only some kinds of bread originally. They decide to share their breakfast together. As we all know, bread with milk leads to the best taste.
XiaoA has kinds of milk, and XiaoB has kinds of bread.Based on their preferences, each milk has a enjoyed value , and each bread has a enjoyed value . Because of hating some kinds of these, or may be negative.
What's more, they should enjoy their milk and bread until there is nothing according to the rules below:
When both of milk and bread left, they choose one kind of milk and one kind of bread to make a pair and enjoy it. They will get the enjoyed value for this pair.
And, if there is some milk left only, they will get the enjoyed value for the kind of milk.
Also, if there is for some left bread only, the enjoyed value is for the kind of bread.
Now they ask you to calculate the maximum sum of the enjoyed value they will get.
Input
The first line of the input is the number of test cases ().
For each case, in the first line there are two integers , (), the number of kinds of milk and bread.The second line has integers (), the third line has integers ().
Output
For each test case, output one line. First, output Case #C:
, where is the number of test case, from to . Then,output the maximum sum of the enjoyed value they will get for this case.
Samples
2
2 2
1 2
3 4
3 1
2 4 5
7
Case #1: 52
Case #2: 164
Note
For the second case, firstly they choose the pair of the milk and the bread get enjoyed value , then they eat the and milk get , so the total enjoyed value is .
Resources
ty12