T, N, Money = map(int, input().split()) S, P, R = [0]*N, [0]*N, [0]*N for week in range(T): L = [0]*N K = sorted(((S[i]+1)**2 * (P[i]+61)**4 // (R[i]+1), i) for i in range(N)) for j, (k, i) in enumerate(K, 1): L[i] = j k = Money//(500*sum(L)) L = [k*l for l in L] print(1, *L, 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()))