mod = 10**9+7 # 行列の乗算(mod) def mat_mul(a, b): I, K, J = len(a), len(b), len(b[0]) c = [[0 for j in range(J)] for i in range(I)] for i in range(I): for k in range(K): for j in range(J): c[i][j] += a[i][k] * b[k][j] c[i][j] %= mod return c # 行列の累乗(mod) def mat_pow(a, n): b = [[0 for j in range(len(a))] for i in range(len(a))] for i in range(len(a)): b[i][i] = 1 while n > 0: if n & 1: b = mat_mul(b, a) a = mat_mul(a, a) n >>= 1 return b n = int(input()) a,b,c = map(int,input().split()) st = [[0]*3 for i in range(3)] st[0][0] = 1 st[0][1] = -1 st[0][2] = 0 st[1][0] = 0 st[1][1] = 1 st[1][2] = -1 st[2][0] = -1 st[2][1] = 0 st[2][2] = 1 A = mat_pow(st,n-1) an = A[0][0]*a+A[0][1]*b+A[0][2]*c bn = A[1][0]*a+A[1][1]*b+A[1][2]*c cn = A[2][0]*a+A[2][1]*b+A[2][2]*c #print(A,a,b,c,an,bn,cn) #print(a,b,A[0]) #print(A) print(an%mod,bn%mod,cn%mod)