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())) que = [] for i in range(N): heappush(que, (-Fraction(A[i], B[0]), i, 0)) for _ in range(M): f, i, j = heappop(que) f = -f print(i+1) if j+1 < M: heappush(que, (-Fraction(A[i], B[j+1]), i, j+1)) else: heappush(que, (0, i, j+1))