import numpy as np a, b = map(int, input().split()) c, d = map(int ,input().split()) w, x = map(int, input().split()) y, z = map(int, input().split()) A = np.array([[a, b], [c, d]]) B = np.array([[w, x], [y, z]]) ans = A @ B @ A @ B for p in ans : for q in p : print(int(q))