## https://yukicoder.me/problems/no/2453 MAXINT = 10 ** 9 + 7 class SegmentTree: """ 非再帰版セグメント木。 更新は「加法」、取得は「最大値」のもの限定。 """ def __init__(self, init_array): n = 1 while n < len(init_array): n *= 2 self.size = n self.array = [[-MAXINT, 1, MAXINT] for _ in range(2 * self.size)] for i, a in enumerate(init_array): self.array[self.size + i] = a end_index = self.size start_index = end_index // 2 while start_index >= 1: for i in range(start_index, end_index): self._op(self.array[i], self.array[2 * i], self.array[2 * i + 1]) end_index = start_index start_index = end_index // 2 def _op(self, array, left, right): l_a = left[0] l_b = left[1] r_a = right[0] r_b = right[1] if l_a * r_b > r_a * l_b: array[0] = l_a array[1] = l_b array[2] = left[2] elif l_a * r_b < r_a * l_b: array[0] = r_a array[1] = r_b array[2] = right[2] else: array[0] = left[0] array[1] = left[1] array[2] = min(left[2], right[2]) def set(self, x, b): index = self.size + x self.array[index][1] = b while index > 1: index //= 2 self._op(self.array[index], self.array[2 * index], self.array[2 * index + 1]) def get_max(self, l, r): L = self.size + l; R = self.size + r # 2. 区間[l, r)の最大値を求める s = [-MAXINT, 1, MAXINT] while L < R: if R & 1: R -= 1 self._op(s, s, self.array[R]) if L & 1: self._op(s, s, self.array[L]) L += 1 L >>= 1; R >>= 1 return s def main(): N, M = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) index_list = [0] * N array = [[A[i], B[0], i] for i in range(N)] seg_tree = SegmentTree(array) for _ in range(M): a, _, j = seg_tree.get_max(0, N) print(j + 1) index_list[j] += 1 if index_list[j] < M: seg_tree.set(j, B[index_list[j]]) if __name__ == '__main__': main()