P13457 [GCJ 2008 #1A] Minimum Scalar Product

Description

You are given two vectors $v_1 = (x_1, x_2, ..., x_n)$ and $v_2 = (y_1, y_2, ..., y_n)$. The scalar product of these vectors is a single number, calculated as $x_1y_1 + x_2y_2 + ... + x_ny_n$. Suppose you are allowed to permute the coordinates of each vector as you wish. Choose two permutations such that the scalar product of your two new vectors is the smallest possible, and output that minimum scalar product.

Input Format

The first line of the input file contains integer number $T$ - the number of test cases. For each test case, the first line contains integer number $n$. The next two lines contain $n$ integers each, giving the coordinates of $v_1$ and $v_2$ respectively.

Output Format

For each test case, output a line Case #$X$: $Y$ where $X$ is the test case number, starting from 1, and $Y$ is the minimum scalar product of all permutations of the two given vectors.

Explanation/Hint

**Limits** **Small dataset (5 Pts, Test set 1 - Visible)** - $T = 1000$ - $1 \leq n \leq 8$ - $-1000 \leq x_i, y_i \leq 1000$ **Large dataset (10 Pts, Test set 2 - Hidden)** - $T = 10$ - $100 \leq n \leq 800$ - $-100000 \leq x_i, y_i \leq 100000$