import fileinput import sys sys.setrecursionlimit(10**6) lines = fileinput.input() def read(conv=str, sep=None): global lines line = lines.readline().strip() if sep is None: return conv(line) else: return [conv(token) for token in line.split(sep)] def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) def solve(N, S): order = [] assigned = set() for i, s in enumerate(S): if i-1 >= 0 and S[i-1] == s: # same block continue if s in assigned: # block in between return None else: # assign new order.append(s) assigned.add(s) return order T = read(int) for t in range(T): N = read(int) S = read(int, ' ') sol = solve(N, S) if sol is None: print("Case #{0}:".format(t + 1), "IMPOSSIBLE") else: print("Case #{0}:".format(t + 1), *sol)