text: //#include <algorithm>
  //#include <bitset>
  //#include <cassert>
  //#include <cctype>
  //#include <climits>
  //#include <cmath>
  //#include <cstdio>
  //#include <cstdlib>
  //#include <cstring>
  //#include <fstream>
  //#include <iostream>
  //#include <iomanip>
  //#include <iterator>
  //#include <list>
  //#include <map>
  //#include <numeric>
  //#include <queue>
  //#include <set>
  //#include <sstream>
  //#include <stack>
  //#include <string>
  //#include <utility>
  //#include <vector>
  #include <bits/stdc++.h>
  using namespace std;
  
  #define    READ(f) 	         freopen(f, "r", stdin)
  #define    WRITE(f)   	     freopen(f, "w", stdout)
  #define    MP(x, y) 	     make_pair(x, y)
  #define    PB(x)             push_back(x)
  #define    FOR(i,L,R) 	     for (int i = (int)(L); i <= (int)(R); i++)
  #define    ROF(i,L,R) 	     for (int i = (int)(L); i >= (int)(R); i--)
  #define    FOREACH(i,t)      for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
  #define    ALL(p) 	         p.begin(),p.end()
  #define    ALLR(p) 	         p.rbegin(),p.rend()
  #define    SET(p) 	         memset(p, -1, sizeof(p))
  #define    CLR(p)            memset(p, 0, sizeof(p))
  #define    MEM(p, v)         memset(p, v, sizeof(p))
  #define    getI(a) 	         scanf("%d", &a)
  #define    getII(a,b) 	     scanf("%d%d", &a, &b)
  #define    getIII(a,b,c)     scanf("%d%d%d", &a, &b, &c)
  #define    getL(a)           scanf("%lld",&a)
  #define    getLL(a,b)        scanf("%lld%lld",&a,&b)
  #define    getLLL(a,b,c)     scanf("%lld%lld%lld",&a,&b,&c)
  #define    getC(n)           scanf("%c",&n)
  #define    getF(n)           scanf("%lf",&n)
  #define    getS(n)           scanf("%s",n)
  #define    bitCheck(N,in)    ((bool)(N&(1<<(in))))
  #define    bitOff(N,in)      (N&(~(1<<(in))))
  #define    bitOn(N,in)       (N|(1<<(in)))
  #define    bitFlip(a,k)      (a^(1<<(k)))
  #define    bitCount(a)        __builtin_popcount(a)
  #define    bitCountLL(a)      __builtin_popcountll(a)
  #define    bitLeftMost(a)     (63-__builtin_clzll((a)))
  #define    bitRightMost(a)    (__builtin_ctzll(a))
  #define    UNIQUE(V)          (V).erase(unique((V).begin(),(V).end()),(V).end())
  #define    vi 	              vector < int >
  #define    vii 	              vector < vector < int > >
  #define    pii 	              pair< int, int >
  #define    ff 	              first
  #define    ss 	              second
  #define    ll	              long long
  #define    ull 	              unsigned long long
  #define    sf scanf
  #define    pf printf
  #define    FMT(...)           (sprintf(CRTBUFF, __VA_ARGS__)?CRTBUFF:0)
  char CRTBUFF[30000];
  
  #ifdef dipta007
       #define debug(args...) {cerr<<"Debug: "; dbg,args; cerr<<endl;}
       #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
          template <typename Arg1>
          void __f(const char* name, Arg1&& arg1){
              cerr << name << " : " << arg1 << std::endl;
          }
          template <typename Arg1, typename... Args>
          void __f(const char* names, Arg1&& arg1, Args&&... args){
              const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
          }
  #else
      #define debug(args...)  /// Just strip off all debug tokens
      #define trace(...) ///yeeeee
  #endif
  
  struct debugger{
      template<typename T> debugger& operator , (const T& v){
          cerr<<v<<" ";
          return *this;
      }
  }dbg;
  
  const double EPS = 1e-9;
  const int INF = 0x7f7f7f7f;
  const double PI=acos(-1.0);
  
  // g++ -g -O2 -std=gnu++11 A.cpp
  // ./a.out
  
  ///****************** template ends here ****************
  
  int t, n, m;
  
  int dp[(1<<14)+4];
  int d[16][16];
  int val[(1<<14)+4];
  int vis[(1<<14)+4];
  int tt;
  
  int get(int mask)
  {
      int res = 0;
      FOR(i,0,n-1)
      {
          if(bitCheck(mask, i) == 1)
          {
              FOR(j,0,n-1)
              {
                  if(bitCheck(mask, j) == 1)
                  {
                      res += d[i][j];
                  }
              }
          }
      }
      return res;
  }
  
  int call(int mask)
  {
      if(mask == 0) return 0;
      int &ret = dp[mask];
      if(vis[mask] == tt) return ret;
      vis[mask] = tt;
  
      ret = 0;
      for ( int sub = 0 ; sub = sub - mask & mask ; )
      {
          if(val[sub] > 0) continue;
          ret = min(ret, val[sub] + call(mask ^ sub));
      }
      return ret;
  }
  
  int main() {
      #ifdef dipta007
          //READ("in.txt");
         //WRITE("out.txt");
      #endif // dipta007
  //    ios_base::sync_with_stdio(0);cin.tie(0);
  
      int t;
      getI(t);
      CLR(vis);
      FOR(ci,1,t)
      {
          tt = ci;
          getI(n);
          FOR(i,0,n-1)
          {
              FOR(j,0,n-1)
              {
                  getI(d[i][j]);
              }
          }
          FOR(i,0,(1<<n)-1)
          {
              val[i] = get(i);
          }
          pf("Case %d: %d\n", ci, call((1<<n)-1));
      }
  
  
      return 0;
  }
  
  
  