""" Blind Bottles Let's build the answer cell by cell from left to right. Call the current index i. 3 cases: 1. a[i] is correct. Then every possible swap decreases the answer by 1 or 2. 2. a[i] is incorrect, there is either only one swap that increases the answer by 2 3. a[i] is incorrect. There are 2 swaps that increase the answer by 1, call them j and k. Then do whatever maximizes the score for all permutations of (i, j, k). Should only need to check orders j k i and k i j. """ import functools import sys @functools.cache def query(a): print(*a, flush=True) k = int(input()) if k == len(a): sys.exit() return k """ ans = list(range(9, 0, -1)) def query(a): k = sum(x == y for x, y in zip(a, ans)) if k == len(a): sys.exit() return k """ def do_swap(a, i, j): b = list(a) b[i], b[j] = b[j], b[i] return tuple(b) def main(): n = int(input()) a = tuple(range(1, n + 1)) for i in range(n): # Figure out the correct value for i base = query(a) nxt = [] for j in range(i + 1, n): b = do_swap(a, i, j) nxt.append((query(b), j)) if all(score < base for score, _ in nxt): pass elif j := max((j for score, j in nxt if base + 2 == score), default=None): a = do_swap(a, i, j) else: j, k = [j for score, j in nxt if base + 1 == score] b = do_swap(do_swap(a, i, j), j, k) c = do_swap(do_swap(a, i, k), j, k) if query(b) > query(c): a = b else: a = c query(a) if __name__ == "__main__": main()