import numpy as np def multiply_matrices(A, B, mod): return (A @ B) % mod def power_matrix(A, n, mod): result = np.identity(len(A), dtype=int) while n > 0: if n % 2 == 1: result = multiply_matrices(result, A, mod) A = multiply_matrices(A, A, mod) n //= 2 return result N = int(input()) mod = 10**9 + 7 p = pow(6, -1, mod) A = np.array([[0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [p, p, p, p, p, p]]) A_powered = power_matrix(A, N, mod) print(A_powered[5][5])