for t in range(int(input())): p = int(input()) s = input().split() # Check if Badari can win possible = True for i in range(p-1): if sorted(s[i]) > sorted(s[i+1]): possible = False break # Output the result if possible: print("Case #{}: POSSIBLE".format(t+1)) print(" ".join("".join(sorted(part)) for part in s)) else: print("Case #{}: IMPOSSIBLE".format(t+1))