import java.io.*; import java.util.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); long n = sc.nextLong() - 1; long[] org = new long[3]; for (int i = 0; i < 3; i++) { org[i] = sc.nextInt(); } long[][] base = new long[60][9]; base[0] = new long[]{1, MOD - 1, 0, 0, 1, MOD - 1, MOD - 1, 0, 1}; for (int i = 1; i < 60; i++) { base[i][0] = (base[i - 1][0] * base[i - 1][0] + base[i - 1][1] * base[i - 1][3] + base[i - 1][2] * base[i - 1][6]) % MOD; base[i][1] = (base[i - 1][0] * base[i - 1][1] + base[i - 1][1] * base[i - 1][4] + base[i - 1][2] * base[i - 1][7]) % MOD; base[i][2] = (base[i - 1][0] * base[i - 1][2] + base[i - 1][1] * base[i - 1][5] + base[i - 1][2] * base[i - 1][8]) % MOD; base[i][3] = (base[i - 1][3] * base[i - 1][0] + base[i - 1][4] * base[i - 1][3] + base[i - 1][5] * base[i - 1][6]) % MOD; base[i][4] = (base[i - 1][3] * base[i - 1][1] + base[i - 1][4] * base[i - 1][4] + base[i - 1][5] * base[i - 1][7]) % MOD; base[i][5] = (base[i - 1][3] * base[i - 1][2] + base[i - 1][4] * base[i - 1][5] + base[i - 1][5] * base[i - 1][8]) % MOD; base[i][6] = (base[i - 1][6] * base[i - 1][0] + base[i - 1][7] * base[i - 1][3] + base[i - 1][8] * base[i - 1][6]) % MOD; base[i][7] = (base[i - 1][6] * base[i - 1][1] + base[i - 1][7] * base[i - 1][4] + base[i - 1][8] * base[i - 1][7]) % MOD; base[i][8] = (base[i - 1][6] * base[i - 1][2] + base[i - 1][7] * base[i - 1][5] + base[i - 1][8] * base[i - 1][8]) % MOD; } for (int i = 59; i >= 0; i--) { if (n >= (1L << i)) { n -= (1L << i); long[] next = new long[3]; next[0] = (base[i][0] * org[0] + base[i][1] * org[1] + base[i][2] * org[2]) % MOD; next[1] = (base[i][3] * org[0] + base[i][4] * org[1] + base[i][5] * org[2]) % MOD; next[2] = (base[i][6] * org[0] + base[i][7] * org[1] + base[i][8] * org[2]) % MOD; org = next; } } System.out.println(org[0] + " " + org[1] + " " + org[2]); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }