n = list(map(int, input().split())) a = list(map(str,input().split())) op = a[0] x = list(map((lambda x: int(x)), a[1:])) y = [int(input()) for i in range(n[0])] if op == "+": for i in range(n[0]): l = [] for j in range(n[1]): l.append(x[j]+y[i]) print(*l) else: for i in range(n[0]): l = [] for j in range(n[1]): l.append(x[j]*y[i]) print(*l)