// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define patkan 9
#define tisic 47
#define soclose 10e-7
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define chocolate win
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):(x))
// mylittlepony
using namespace std;

int main() {
    //freopen("dice.in","r",stdin);
    int T;
    scanf(" %d",&T);
    
    for(int t =0; t < T; t++) {
        int N;
        cin >> N;
        vector<int> V(N);
        vector<bool> is(5001,false);
        for(int i =0; i < N; i++) scanf(" %d",&V[i]);
        vector<int> A(6,0); A[0] =1;
        vector<int> B(6,0); B[0] =V[0]-1;
        int S =0;
        for(int i =N-1; i >= 0; i--) {
            V[i] -=V[0];
            S +=V[i];
            is[V[i]] =true;}

        bool ok =false;
        int op =0;
        for(int a =2+(int)(N == 36); a < min(12,N-8); a++) if(!ok) 
       	for(int b =a+1; b < N-7; b++) if(!ok && !(N == 36 && b < 5)) 
       	for(int c =b+1; c < N-6; c++) if(!ok && !(N == 36 && c < 8)) 
       	for(int d =c+1; d < N-5; d++) if(!ok) 
       	for(int e =d+1; e < N-4; e++) if(!ok)
       	for(int f =e+1; f < N-3; f++) if(!ok) {
       		vector<int> x(6,0), y(6,0);
       		x[1] =V[1];
           	y[1] =V[a]-x[1];
           	x[2] =V[b]-y[1]; if(y[1] > V[2] && x[2] > V[2]) continue;
           	y[2] =V[c]-x[2];
           	x[3] =V[d]-y[2];
       		y[3] =V[e]-x[3];
           	x[4] =V[f]-y[3];
       		int Sx =x[1]+x[2]+x[3]+x[4];
       		int Sy =y[1]+y[2]+y[3];
           	if(N == 36) y[4] =(S/6-Sx-Sy-V[N-1]);
           	bool ok1 =true;
           	for(int i =0; i < 5; i++) for(int j =0; j < 4+(int)(N == 36); j++)
           		if(x[i] < 0 || y[j] < 0 || !is[x[i]+y[j]]) {
           			ok1 =false; 
           			break;}
            if(!ok1) continue;

        	for(int g =f+1; g < ((N == 36)?(f+2):(N-2)); g++) if(!ok) 
        	for(int h =max(N-7,g+1); h < N-1; h++) {
        		if(N != 36) y[4] =V[g]-x[4]; if(y[4] < 0 || !is[y[4]]) continue;
        		x[5] =V[h]-y[4]; if(x[5] < 0 || !is[x[5]]) continue;
            	y[5] =V[N-1]-x[5]; if(y[5] < 0 || !is[y[5]]) continue;
	
	            set<int> S;
    	        for(int i =0; i < 6; i++) for(int j =0; j < 6; j++)
        	        S.insert(x[i]+y[j]);
            	if(S == set<int>(V.begin(),V.end())) {
            	    for(int i =0; i < 6; i++) A[i] =A[0]+x[i];
            	    for(int i =0; i < 6; i++) B[i] =B[0]+y[i];
            	    ok =true;}
            	if(ok) break;}}

        printf("Case %d:\n",t+1);
        for(int i =0; i < 6; i++) {
            if(i > 0) printf(" ");
            printf("%d",A[i]);}
        printf("\n");
        for(int i =0; i < 6; i++) {
            if(i > 0) printf(" ");
            printf("%d",B[i]);}
        printf("\n");}
    return 0;}
        
// look at my code
// my code is amazing