#include <algorithm>#include <iostream>#include <cstring>#include <sstream>#include <vector>#include <cmath>#include <set>#include <map>#include <iomanip> using namespace std; #define int long long #define ff first#define ss second#define mp make_pair#define sqr(x) ((x)*(x)) typedef long long ll;typedef pair <int, int> pie;typedef pair <int, int> pii; int n;int mat[20][20];pii dp[1<<15]; inline void main2(){ cin >> n; for (int i=0; i<n; i++) for (int j=0; j<n; j++) cin >> mat[i][j]; for (int i=0; i<(1<<n); i++) dp[i] = pii(-1,0); dp[0] = pii(0,0); for (int mask=1; mask<(1<<n); mask++){ for (int i=0; i<n; i++) if (mask & (1<<i)){ int maxi = 0; for (int j=0; j<n; j++) if (mask & (1<<j)) maxi = max(maxi, mat[j][i]); dp[mask] = max(dp[mask], pii(dp[mask ^ (1<<i)].first + maxi, dp[mask ^ (1<<i)].second * 10 - i)); } } cout << fixed << setprecision(2) << dp[(1<<n)-1].first/100.0 << endl; int cur = -dp[(1<<n)-1].second; string ret(n, 'A'); for (int i=0; i<n; i++){ ret[n-1-i] = char('A' + cur%10); cur/=10; } cout << ret << endl;} main() { ios::sync_with_stdio (false); int testCase; cin >> testCase; for (int o=1; o<=testCase; o++){ main2(); } return 0;}