T, N, money = map(int, input().split()) s, p, r = [0] * N, [0] * N, [0] * N def do(arg): if type(arg) == list: print(1, *arg, flush=True) else: print(2, arg, flush=True) money = int(input()) if money == -1: exit() s = list(map(int, input().split())) p = list(map(int, input().split())) r = list(map(int, input().split())) return money, s, p, r for week in range(T): money, s, p, r = do([money // (500 * N)] * N)