cases = int(input()) for case in range(1, cases+1): n = int(input()) vals = list(map(int, input().split())) first_location = {} last_location = {} count = {} for i, v in enumerate(vals): if v not in first_location: first_location[v] = i last_location[v] = i if v not in count: count[v] = 0 count[v] += 1 bad = False for v in vals: if last_location[v] - first_location[v] != count[v] - 1: bad = True if bad: print(f"Case #{case}: IMPOSSIBLE") else: # sorted dict gaming print(f"Case #{case}: {' '.join(map(str, first_location.keys()))}")