#include using namespace std; #define reg register typedef long long ll; #define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i) #define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i) typedef pair Pii; typedef unsigned long long ull; typedef double db; #define mp make_pair #define pb push_back #define Mod1(x) ((x>=P)&&(x-=P)) #define Mod2(x) ((x<0)&&(x+=P)) template inline void cmin(T &a,T b){ ((a>b)&&(a=b)); } template inline void cmax(T &a,T b){ ((a T rd(){ T s=0; int f=0; while(!isdigit(IO=getchar())) if(IO=='-') f=1; do s=(s<<1)+(s<<3)+(IO^'0'); while(isdigit(IO=getchar())); return f?-s:s; } const int N=1e5+10; int n; char s[N]; int cnt[10]; int dp[6][1<<10]; int main(){ rep(kase,1,rd()) { n=rd(); memset(cnt,0,sizeof cnt); rep(i,1,n) { scanf("%s",s); cnt[s[strlen(s)-1]-'0']++; } memset(dp,-63,sizeof dp); dp[0][0]=1e9; rep(i,1,5) { rep(S,0,(1<<10)-1) if(dp[i-1][S]>=0) { rep(T,0,(1<<10)-1) if((S&T)==0) { int s=0; rep(j,0,9) if(T&(1<