from fractions import Fraction from heapq import heappush, heappop N, M = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) def IDX(i, j): return i*(M+1)+j def IDXR(n): return n//(M+1), n%(M+1) que = [] for i in range(N): heappush(que, (-Fraction(A[i], B[0]), IDX(i, 0))) for _ in range(M): f, n = heappop(que) i, j = IDXR(n) f = -f print(i+1) if j+1 < M: heappush(que, (-Fraction(A[i], B[j+1]), IDX(i, j+1))) else: heappush(que, (0, IDX(i, M)))