1. 
/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 11790 - Murcia's Skyline
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=117&page=show_problem&problem=2890
*
* @author Evgeni Pavlidis
* @version 1.0, 06/02/2010
*
* Method : DP - LIS/LDS
* Status : Accepted
* Runtime: 0.948
*/

import java.io.*;
import java.util.*;

class Main {

public static void main(String...args)
{
Scanner sc = new Scanner(System.in);
int testCases = sc.nextInt();
int n, maxInc, maxDec;
int[] h, w, dpInc, dpDec;


for(int t = 1; t <= testCases; t++)
{
n = sc.nextInt();

h = new int[n];
w = new int[n];
dpInc = new int[n];
dpDec = new int[n];
maxInc = 0;
maxDec = 0;

// read heights
for(int i = 0; i < n; i++)
h[i] = sc.nextInt();

// read widths and init max
for(int i = 0; i < n; i++)
{
w[i] = dpInc[i] = dpDec[i] = sc.nextInt();

if(w[i] > maxInc)
maxInc = maxDec = w[i];
}

for(int i = 1; i < n; i++)
for(int j = 0; j < i; j++)
{
// find longest increasing subsequenche
if(h[j] < h[i])
{
dpInc[i] = Math.max(dpInc[i], dpInc[j] + w[i]);

if(dpInc[i] > maxInc)
maxInc = dpInc[i];
}

// find longest decreasing subsequenche
if(h[j] > h[i])
{
dpDec[i] = Math.max(dpDec[i], dpDec[j] + w[i]);

if(dpDec[i] > maxDec)
maxDec = dpDec[i];
}

}

if(maxInc >= maxDec)
System.out.printf("Case %d. Increasing (%d). Decreasing (%d).\n", t, maxInc, maxDec);
else
System.out.printf("Case %d. Decreasing (%d). Increasing (%d).\n", t, maxDec, maxInc);

}
}
}