fork(1) download
  1. def solve():
  2. n, s = map(int, input().split())
  3. a = list(map(int, input().split()))
  4.  
  5. summation = 0
  6. c1 = 0
  7. c2 = 0
  8. c3 = 0
  9.  
  10. for val in a:
  11. summation += val
  12. if val == 0:
  13. c1 += 1
  14. elif val == 1:
  15. c2 += 1
  16. elif val == 2:
  17. c3 += 1
  18.  
  19. if s < summation or s == summation + 1:
  20. print('0 ' * c1 + '2 ' * c3 + '1 ' * c2)
  21. else:
  22. print(-1)
  23. t=int(input())
  24. for i in range(t):
  25. solve()
  26.  
Success #stdin #stdout 0.13s 14056KB
stdin
6
3 2
0 1 2
3 3
0 1 2
3 6
0 1 2
3 4
0 1 2
3 10
0 1 2
5 1000
2 0 1 1 2
stdout
0 2 1 
-1
-1
0 2 1 
-1
-1