N, M = [int(i) for i in input().strip().split(' ')] tmp = [i for i in input().strip().split(' ')] op = tmp[0] B = [i for i in tmp[1:]] A = [input().strip() for _ in range(N)] print('\n'.join([' '.join([str(eval(A[y] + op + B[x])) for x in range(M)]) for y in range(N)]))