Start: Jul, 06, 2019 10:00:00
20190706Python程序设计基础培训扩展练习
End: Jul, 17, 2019 12:00:00
Time elapsed:
Time remaining:

Problem_ID: K
Result: Accepted
Time: 44ms
Memory: 25184kB
Author: 13868552080
In contest: 1300

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())