import numpy as np MOD=10**9+7 def mul(a,b): return np.dot(a,b)%MOD N=int(input()) A,B,C=map(int,input().split()) a=np.array([[1,-1,0],[0,1,-1],[-1,0,1]],dtype=np.int64) vec=np.array([[A],[B],[C]],dtype=np.int64) mat=np.eye(3,dtype=np.int64) N=N-1 while N>0: if N%2==1: mat=mul(mat, a) a=mul(a,a) N//=2 vec=mul(mat,vec) print(vec[0][0],vec[1][0],vec[2][0])