def xgfc(a,b):
l=[]
r=[]
while a!=0:
g=a%10
a=a//10
l.append(g)
l.sort()
while b!=0:
g=b%10
b=b//10
r.append(g)
r.sort()
if l==r:
return True
else:
return False
n=int(input())
while n!=0:
x=list(map(int,input().split()))
x.sort()
i=0
while i<len(x):
j=0
f=0
while j<len(x):
if xgfc(x[i],x[j]) and i!=j:
del x[j]
j=j-1
f=1
j=j+1
if f==1:
del x[i]
i=i-1
i=i+1
if len(x)==0:
print("None")
else:
for y in x:
print(y,end=' ')
print()
n=int(input())