n, m = map(int, input().split()) op, *B = input().split() B = list(map(int, B)) for _ in range(n): a = int(input()) print(*({"+":a+b, "*":a*b}[op] for b in B))