n,k = map(int,input().split()) bn = input().split() ope = bn[0] bn = bn[1:] an = [input() for i in range(n)] for i in range(n): result = [] for j in range(k): result.append(str(eval(an[i]+ope+bn[j]))) print(*result)