#include <cstdio>
#include <fstream>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 50000*200+5
#define SIG 2
struct Trie {
int ch[N][SIG], len[N], visit[N];
int sz;
void reset() {
sz=1;
memset(ch[0],0,sizeof(ch[0]));
memset(visit,0,sizeof(visit));
}
void insert(char* s){
int u=0 ;
for (int i=0;s[i];i++) {
int c=s[i]-'0';
if (!ch[u][c]) {
memset(ch[sz],0,sizeof(ch[sz]));
len[sz]=len[u]+1;
ch[u][c]=sz++;
}
u=ch[u][c];
visit[u]++;
}
}
int query()
{
int ans=0;
for (int i=0;i<sz;i++)
ans=max(ans,visit[i]*len[i]);
return ans;
}
}trie;
int main()
{
freopen("1.in","r",stdin);
int T,n;
scanf("%d",&T);
while (T--) {
trie.reset();
scanf("%d",&n);
char s[250];
for (int i=0;i<n;i++) {
scanf("%s",s);
trie.insert(s);
}
printf("%d\n",trie.query());
}
return 0;
}
09-02