t = int(input()) for i in range(1, t+1): n = int(input()) arr = list(map(int, input().split())) color_freq = {} for c in arr: if c not in color_freq: color_freq[c] = 1 colors = sorted(color_freq.keys()) impossible = False result = [-1] * n for idx, color in enumerate(colors): color_idx = [i for i in range(n) if arr[i] == color] num_cards = len(color_idx) if idx == 0: if num_cards > 1: impossible = True break result[color_idx[0]] = 1 continue if num_cards == 1: result[color_idx[0]] = max(result[color_idx[0]-1] + 1, 1) else: diff = result[color_idx[0]] - result[color_idx[1]] if diff < 0: impossible = True break for i in range(1, num_cards): if result[color_idx[i-1]] - result[color_idx[i]] != diff: impossible = True break result[color_idx[i]] = result[color_idx[i-1]] if impossible: break if impossible: print("Case #{}: IMPOSSIBLE".format(i)) else: print("Case #{}: {}".format(i, " ".join(str(result[i]) for i in range(n)))))