import numpy as np mod=10**9+7 m=np.matrix([[1,-1,0],[0,1,-1],[-1,0,1]]) t=np.linalg.matrix_power(m,int(input())-1) a,b,c=map(int,input().split()) ans=np.matrix([[a],[b],[c]]) print(*map(lambda x:int(x)%mod,t*ans))