#include #define ll long long using namespace std; int T,n,c[10]; char s[10]; int S=1<<10,dp[6][1<<10],p[1<<10]; int read(){ int x=0;char ch=getchar(); while(!isdigit(ch)) ch=getchar(); while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar(); return x; } void print(ll x){ if(x>=10) print(x/10); putchar(x%10+'0'); } int main(){ T=read(); while(T--){ n=read(); memset(c,0,sizeof(c)); for(int i=1;i<=n;i++){ scanf("%s",s+1); c[s[5]-'0']++; } memset(dp,0x3f,sizeof(dp)); memset(p,0,sizeof(p)); for(int i=0;i