Minimum Scalar Product (Small)
InterviewTime limit5sMemory limit512 MB
Permute two vectors to minimize their dot product and print the minimum.
Problem
You are given two vectors and . The scalar product of the two vectors is a single number, computed as .
You may permute the coordinates of each vector however you like. Choose two permutations that make the scalar product of the resulting vectors as small as possible, then print that minimum scalar product.
Input
The first line contains the number of test cases . For each test case, the first line contains an integer , and the next two lines contain integers each, giving the coordinates of and in order.
Limits
Output
For each test case, print one line
Case #X: Y
where is the test case number starting from 1, and is the minimum scalar product over all permutations of the two given vectors.