from operator import add, mul from sys import stdin def main(): input = lambda: stdin.readline()[:-1] N, M = map(int, input().split()) B = input().split() A = [int(input()) for _ in [0] * N] if B[0] == '+': func = add else: func = mul for a in A: ans = [] for b in B[1:]: ans.append(func(a, int(b))) print(*ans) main()