mod = 10 ** 9 + 7 def matrix_multiplication(a, b): n = len(a) res = [[0] * n for i in range(n)] for i in range(n): for k in range(n): for j in range(n): res[i][j] += a[i][k] * b[k][j] res[i][j] %= mod return res def matrix_pow(a, k): n = len(a) res = [[0] * n for i in range(n)] for i in range(n): res[i][i] = 1 while k: if k & 1: res = matrix_multiplication(res, a) a = matrix_multiplication(a, a) k >>= 1 return res n = int(input()) a, b, c = map(int, input().split()) M = [[1, -1, 0], [0, 1, -1], [-1, 0, 1]] M = matrix_pow(M, n - 1) print(sum(M[0][i] * [a, b, c][i] for i in range(3)) % mod, end=" ") print(sum(M[1][i] * [a, b, c][i] for i in range(3)) % mod, end=" ") print(sum(M[2][i] * [a, b, c][i] for i in range(3)) % mod)