N=int(input().split()[0]) c=input().split() for _ in range(N): a=input() print(*[eval(a+c[0]+b) for b in c[1:]])