Artifact e9cb1325b5300e50a4d168a688ed3ee438d3c7eb
import java.io.*;
import java.util.*;
public class <CLASSNAME>
{
public static void main(String[] arg)
{
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int C=1; C<=T; ++C)
{
System.out.printf("Case #%d: ", C);
(new <CLASSNAME>(sc)).caseMain();
}
}
Scanner sc;
<CLASSNAME>( Scanner sc ) { this.sc = sc; }
void caseMain()
{
int n = sc.nextInt();
long[] x = new long[n];
for(int i=0; i<n; ++i) x[i] = sc.nextInt();
long[] y = new long[n];
for(int i=0; i<n; ++i) y[i] = sc.nextInt();
System.out.println(solve(x, y, n));
}
long solve(long[] x, long[] y, int n)
{
Arrays.sort(x);
Arrays.sort(y);
long s = 0;
for(int i=0; i<n; ++i)
s += x[i] * y[n-1-i];
return s;
}
}