#include<bits/stdc++.h>
using namespace std;
#define ms(arr,a) memset(arr,a,sizeof arr)
#define debug(x) cout<<"< "#x" = "<<x<<" >"<<endl
const int maxn=4e5;
const int INF=0x3f3f3f3f;
char s[maxn];
int sa[maxn],Rank[maxn],height[maxn],a[maxn],b[maxn],rmq[maxn][50];
int x[maxn],y[maxn],c[maxn];
int len,tot;
void build()
{
int n=strlen(s),m=128;
//int *x=new int[n],*y=new int[n],*c=new int[n+128];
for(int i=0;i<m;++i)c[i]=0;
for(int i=0;i<n;++i)c[x[i]=s[i]]++;
for(int i=1;i<m;++i)c[i]=c[i]+c[i-1];
for(int i=n-1;i>=0;--i)sa[--c[x[i]]]=i;
for(int k=1;k<=n;k<<=1)
{
int p=0;
for(int i=n-k;i<n;++i)y[p++]=i;
for(int i=0;i<n;++i)if(sa[i]>=k)y[p++]=sa[i]-k;
for(int i=0;i<m;++i)c[i]=0;
for(int i=0;i<n;++i)c[x[y[i]]]++;
for(int i=1;i<m;++i)c[i]+=c[i-1];
for(int i=n-1;i>=0;--i)sa[--c[x[y[i]]]]=y[i];
swap(x,y);
p=1;x[sa[0]]=0;
for(int i=1;i<n;++i)x[sa[i]]=y[sa[i-1]]==y[sa[i]]&&y[sa[i-1]+k]==y[sa[i]+k]?p-1:p++;
if(p>=n)break;
m=p;
}
//delete[] x,y,c;
for(int i=0;i<n;++i)Rank[sa[i]]=i;
int len=0;
for(int i=0;i<n;++i)
{
if(len)len--;
if(Rank[i]==0)continue;
int j=sa[Rank[i]-1];
while(s[i+len]==s[j+len])len++;
height[Rank[i]]=len;
}
for(int i=1;i<n;++i)rmq[i][0]=height[i];
for(int i=1;(1<<i)<n;++i)for(int j=1;j+(1<<i)<=n;++j)rmq[j][i]=min(rmq[j][i-1],rmq[j+(1<<(i-1))][i-1]);
}
int lcp(int a,int b)
{
if(a==b)return strlen(s+sa[a]);
if(a>b)swap(a,b);
int k=0;
while((1<<(k+1))<=b-a)k++;
return min(rmq[a+1][k],rmq[b-(1<<k)+1][k]);
}
int main()
{
freopen("Input.txt","r",stdin);
int T;scanf("%d",&T);
for(int Case=1;Case<=T;++Case)
{
int n;
scanf("%d%s",&n,s);
len=strlen(s);
for(int i=0;i<n-1;++i)
{
int pos=strlen(s);
s[pos]='.';
scanf("%s",s+pos+1);
}
tot=strlen(s);
build();
int tmp=0;
a[0]=-1,b[tot-1]=-1;
for(int i=1;i<tot;++i)
{
if(sa[i-1]<len)a[i]=a[i-1];
else a[i]=i-1;
if(sa[tot-i]<len)b[tot-i-1]=b[tot-i];
else b[tot-i-1]=tot-i;
}
int ans=INF,ansp;
for(int i=0;i<len;++i)
{
int pos=Rank[i],mLen;
if(a[pos]==-1)mLen=lcp(pos,b[pos]);
else if(b[pos]==-1)mLen=lcp(pos,a[pos]);
else mLen=max(lcp(pos,b[pos]),lcp(pos,a[pos]));
if(mLen+i>=len)break;
mLen++;
if(mLen<ans)ans=mLen,ansp=pos;
if(mLen==ans&&pos<ansp)ansp=pos;
}
printf("Case #%d: ",Case);
if(ans==INF)printf("Impossible
");
else
{
for(int i=0;i<ans;++i)printf("%c",s[sa[ansp]+i]);
printf("
");
}
}
}