#include <bits/stdc++.h>

using namespace std;

struct node{
	int x,y,z;
	node(int x,int y,int z):x(x),y(y),z(z){}
	bool operator<(const node& b)const{
		if (x==b.x){
			if (y==b.y){
				return z<b.z;
			}
			return y<b.y;
		}
		return x<b.x;
	}
};

map<node,int> g;
vector<int> v;
int a[5];
int f[5];

void dfs(int now){
	if (now>3){
		node p(a[1],a[2],a[3]);
		if (g.find(p)==g.end()){
			printf("%d %d %d\n",a[1],a[2],a[3]);
			g[p]=1;
		}
	}
	for (int i=0;i<3;i++)
		if (f[i]==0){
			f[i]=1;
			a[now]=v[i];
			dfs(now+1);
			f[i]=0;
		}
}

int main(){
	int T,x,y,z;
	scanf("%d",&T);
	for (int ti=1;ti<=T;ti++){
		scanf("%d%d%d",&x,&y,&z);
		v.clear();
		g.clear();
		v.push_back(x);v.push_back(y);v.push_back(z);
		sort(v.begin(),v.end());
		memset(f,0,sizeof(f));
		printf("Case #%d:\n",ti);
		dfs(1);
	}
	return 0;
}
