from operator import add, mul import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) n, m = map(int, input().split()) op, *B = input().split() B = list(map(int, B)) A = [int(input()) for _ in range(n)] op = add if op == "+" else mul for a in A: for b in B: print(op(a, b), end=" ") print()