/*
分析:
欧拉回路~
并查集只是辅助的,看图是不是强连通的。
2012-07-16
*/
#include"stdio.h"
#include"string.h"
int set[30];
void build(n)
{
int i;
for(i=1;i<=n;i++) set[i]=i;
}
int find(int k)
{
if(set[k]==k) return k;
set[k]=find(set[k]);
return set[k];
}
void Union(int f1,int f2)
{
set[f2]=f1;
}
int main()
{
int T;
int n;
int i;
int a,b;
int num;
char str[1011];
int h_in[30],h_out[30];
int f1,f2,f3;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
build(26);
memset(h_in,0,sizeof(h_in));
memset(h_out,0,sizeof(h_out));
for(i=0;i<n;i++)
{
scanf("%s",str);
a=str[0]-'a'+1;
b=str[strlen(str)-1]-'a'+1;
h_in[b]++;
h_out[a]++;
f1=find(a);
f2=find(b);
if(f1!=f2) Union(f1,f2);
}
num=0;
for(i=1;i<=26;i++) if(set[i]==i&&(h_in[i]||h_out[i])) num++;
if(num>1) {printf("The door cannot be opened.\n");continue;}
f1=f2=f3=0;
for(i=1;i<=26;i++)
{
if(h_in[i]-h_out[i]==1) f1++;
else if(h_in[i]-h_out[i]==-1) f2++;
else if(h_in[i]-h_out[i]==0) f3++;
}
if(f1==1&&f1==f2&&f1+f2+f3==26) printf("Ordering is possible.\n");
else if(f1==0&&f2==0&&f3==26) printf("Ordering is possible.\n");
else printf("The door cannot be opened.\n");
}
return 0;
}