# import sys; input = sys.stdin.buffer.readline # sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") from fractions import gcd def getlist(): return list(map(int, input().split())) #処理内容 def main(): N, M = getlist() B = list(input().split()) if B[0] == "+": for i in range(N): A = int(input()) ans = [None] * M for j in range(1, M + 1): ans[j - 1] = A + int(B[j]) print(*ans) else: for i in range(N): A = int(input()) ans = [None] * M for j in range(1, M + 1): ans[j - 1] = A * int(B[j]) print(*ans) if __name__ == '__main__': main()