from collections import * import heapq import bisect INF = float("inf") MOD = 998244353 # modなし # A*B def mat_mul(A, B): C = [[0] * len(B[0]) for i in range(len(A))] for i in range(len(A)): for k in range(len(B)): for j in range(len(B[0])): C[i][j] = C[i][j] + A[i][k] * B[k][j] return C # A**n def mat_pow(A, n): B = [[0] * len(A) for i in range(len(A))] for i in range(len(A)): B[i][i] = 1 while n > 0: if n & 1 == 1: B = mat_mul(A, B) A = mat_mul(A, A) n = n >> 1 return B # フィボナッチ数列の例 # N=int(input()) # if N==0 or N==1: # print(1) # exit() # mat=[[1,1],[1,0]] # init=[[1],[1]] # mat_=mat_pow(mat,N-1) # print(mat_mul(mat_,init)[0][0]) M = [list(map(int, input().split())) for _ in range(2)] # print(mat_pow(M, 3)) mat = mat_pow(M, 3) for m in mat: print(*m)