#include <bits/stdc++.h>
#define pb push_back
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
using namespace std;
typedef long long LL;
const int INF=1e9;

int n,m;
int a[21][501];
int msk[2000000],cnt;

int f[2];

void gao(int s,int st) {  //
	msk[++cnt]=st;
	for (int i=s+1;i<=n;i+=2)
		gao(i,st|(1<<(i-1)));
}
int sol(int msk) {
	//cout<<msk<<endl;
	for (int i=1;i<=m;i++) {
		int tmp=msk,sum=0;
		for (int j=1;j<=n;j++,tmp>>=1)
			if (tmp&1) sum+=a[j][i];

		if (i<=2) {
			if (i==1) f[1]=sum;
			else f[0]=max(sum+f[1],sum);
		}
		else {
			if (i&1) f[1]=max(f[1],max(sum+f[0],sum));
			else f[0]=max(f[0],max(sum+f[1],sum));
		}
		//cout<<i<<" "<<f[i&1]<<endl;
		//if (msk==3) cout<<i<<" "<<f[i&1]<<endl;
	}
	
	return m==1?f[1]:max(f[1],f[0]);
}
int main() {
	int T; scanf("%d",&T);
	for (int tt=1;T--;tt++) {
		scanf("%d%d",&n,&m);
		for (int i=1;i<=n;i++)
			for (int j=1;j<=m;j++) scanf("%d",&a[i][j]);
		
		cnt=0;
		for (int i=1;i<=n;i++) gao(i,1<<(i-1));

		int ans=-INF;
		FOR (i,1,cnt) ans=max(ans,sol(msk[i]));
		printf("Case #%d: %d\n",tt,ans);
	}
	return 0;
}

