python:
s0=int(input())
for _ in range(s0):
nothing=int(input())
arr=[int(x) for x in input().split()]
three=arr.count(3)
six=arr.count(6)
nine=arr.count(9)
zero=arr.count(0)
v=0
if(sum(arr)%9==6):
if(six>0):
arr.remove(6)
elif(arr.count(3)>=2):
arr.remove(3)
arr.remove(3)
else:
v=1
if(sum(arr)%9==3):
if(three>0):
arr.remove(3)
elif(six>=2):
arr.remove(6)
arr.remove(6)
else:
v=1
if(three ==0 and six ==0 and nine ==0):
if zero>0:
print('0')
else:
print('-1')
elif(len(arr)>0):
print(*sorted(arr,reverse=True),sep=' ')
else:
print('-1')
文章標籤
全站熱搜

寫太長,差評