#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int inde[27];
int outde[27];
int p[27];
int rank[27];
int vis[27];
char str[100005];
void make_set()
{
int i;
for(i=0;i<27;i++)
{
p[i]=i;
rank[i]=0;
}
}
int find_set(int i)
{
if(i!=p[i])
p[i]=find_set(p[i]);
return p[i];
}
int Union(int x,int y)
{
x=find_set(x);
y=find_set(y);
if(x==y)
return 0;
if(rank[x]<rank[y])
p[x]=y;
else
{
p[y]=x;
if(rank[x]==rank[y])
rank[x]++;
}
return 1;
}
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
int i;
int s=0;
int t;
scanf("%d",&t);
memset(inde,0,sizeof(inde));
memset(outde,0,sizeof(outde));
memset(vis,0,sizeof(vis));
make_set();
int tt=0;
for(i=0;i<t;i++)
{
scanf("%s",str);
int t1=str[0]-'a';
int t2=str[strlen(str)-1]-'a';
if(!vis[t1])
{
vis[t1]=1;
tt++;
}
if(!vis[t2])
{
vis[t2]=1;
tt++;
}
if(Union(t1,t2))
s++;
outde[t1]++;
inde[t2]++;
}
if(s!=tt-1)
printf("The door cannot be opened.\n");
else
{
int flag1=0;
int flag2=0;
for(i=0;i<26;i++)
{
if(inde[i]-outde[i]==1)
flag1++;
if(outde[i]-inde[i]==1)
flag2++;
if(outde[i]-inde[i]>1||inde[i]-outde[i]>1)
break;
}
if(i>=26&&((flag1==1&&flag2==1)||(flag1==0&&flag2==0)))
printf("Ordering is possible.\n");
else
printf("The door cannot be opened.\n");
}
}
return 0;
}