Minimum Scalar Product (Large)

Reorder the coordinates of two equal-length integer vectors so their scalar product is as small as possible, and report that minimum for each test case.

Medium4SortingGreedyMathImplementationInterviewNo attempts yetTime limit5sMemory limit512 MB

Problem

You are given two integer vectors of the same length, v1=(x1,x2,,xn)v_1 = (x_1, x_2, \dots, x_n) and v2=(y1,y2,,yn)v_2 = (y_1, y_2, \dots, y_n). The scalar product of the two vectors is the single number x1y1+x2y2++xnynx_1 y_1 + x_2 y_2 + \dots + x_n y_n.

You may reorder the coordinates of each vector however you like. Permute the coordinates of both vectors so that the scalar product is as small as possible, and print that minimum.

Input

The first line contains the number of test cases TT.

Each test case takes three lines. The first line contains an integer nn. The next two lines contain nn integers each: the coordinates of v1v_1 on the second line and the coordinates of v2v_2 on the third line.

Limits

  • 1T101 \le T \le 10
  • 1n8001 \le n \le 800
  • 100000xi,yi100000-100000 \le x_i, y_i \le 100000

Output

For each test case, print one line in this format.

Case #X: Y

XX is the test case number starting from 1, and YY is the smallest scalar product obtainable by permuting the coordinates of the two vectors.