#include #define fi first #define se second #define pb push_back #define SZ(x) ((int)x.size()) #define L(i,u) for (register int i=head[u]; i; i=nxt[i]) #define rep(i,a,b) for (register int i=(a); i<=(b); i++) #define per(i,a,b) for (register int i=(a); i>=(b); i--) using namespace std; typedef long long ll; typedef unsigned int ui; typedef pair Pii; typedef vector Vi; template inline void read(T &x){ x=0; char c=getchar(); int f=1; while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();} while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f; } template inline void umin(T &x, T y){x=x inline void umax(T &x, T y){x=x>y?x:y;} inline ui R() { static ui seed=416; return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13; } const int N = 1015; int n,l[N];char s[12][N]; int bh[12][N],num;Pii dy[N]; ll dp[1<<10|3][N][2]; int ch[1002*1003][26],tot; struct Trie{ int f[N][N]; void ini(bool flip){ rep(t,1,n)rep(a,1,l[t]){ int cur=0;rep(b,a,l[t]){ int c=s[t][!flip?b:l[t]-b+1]-'a'; assert(c>=0&&c<26); if(!ch[cur][c])ch[cur][c]=++tot; cur=ch[cur][c];f[bh[t][a]][bh[t][b]]=cur; } } } }c[2]; inline int getval(int tp, int i, int l, int r){ return c[tp].f[bh[i][l]][bh[i][r]]; } inline int getval(int i, int L, int R){ if(L<=R)return getval(0,i,L,R); return getval(1,i,l[i]-L+1,l[i]-R+1); } int main() { int T;read(T);while(T--){ read(n);rep(i,1,n){ scanf("%s",s[i]+1);l[i]=strlen(s[i]+1); } num=0; rep(i,1,n)rep(j,0,l[i])bh[i][j]=++num,dy[num]=Pii(i,j); rep(i,0,tot)memset(ch[i],0,sizeof(ch[i]));tot=0; c[0].ini(0);c[1].ini(1); // rep(t,0,1)rep(i,1,n)rep(a,1,l[i])rep(b,a,l[i])printf("%d %d %d %d:%d\n",t,i,a,b,getval(t,i,a,b)); int all=(1<>i-1&1))rep(p,0,1){ if(l[x]-y>=l[i]){ if(getval(k,dy[j].fi,dy[j].se+1,dy[j].se+l[i])==getval(p,i,1,l[i])) dp[s|(1<