import java.io.*; import java.util.StringTokenizer; /** * Date: 2025/3/26 17:47 */ public class Main { static int n;//矩阵的长度和宽度 n * n 的矩阵 static int mod = (int) (1e9 + 7); static long[][] A; static long[][] res; //两矩阵相乘 static long[][] multi(long[][] a, long[][] b) { long[][] t = new long[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { t[i][j] += a[i][k] * b[k][j]; t[i][j] %= mod; } } } return t; } //k 个矩阵相乘 static void quickPow(long k) { for (int i = 0; i < n; i++) res[i][i] = 1;//构造单位矩阵 while (k > 0) { if ((k & 1) == 1) res = multi(res, A); A = multi(A, A); k >>= 1; } } //入口,传入一个矩阵和一个整数 k ,返回该矩阵的 k 次幂 static long[][] getRes(int[][] a, long k) { n = a.length; A = new long[n][n]; res = new long[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { A[i][j] = a[i][j]; } } quickPow(k); return res; } public static void main(String[] args) { long n = sc.nextLong(); int[] a = new int[3]; for (int i = 0; i < 3; i++) { a[i] = sc.nextInt(); } int[][] mat = {{1, -1, 0}, {0, 1, -1}, {-1, 0, 1}}; long[][] z = getRes(mat, n - 1); for (int i = 0; i < 3; i++) { long v = 0; for (int j = 0; j < 3; j++) { v += z[i][j] * a[j]; } v = (v % mod + mod) % mod; out.print(v+" "); } out.close(); } static Kattio sc = new Kattio(); static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); static class Kattio { static BufferedReader r; static StringTokenizer st; public Kattio() { r = new BufferedReader(new InputStreamReader(System.in)); } public String next() { try { while (st == null || !st.hasMoreTokens()) { st = new StringTokenizer(r.readLine()); } return st.nextToken(); } catch (Exception e) { return null; } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } } }