import sys; input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") import numpy as np def getlist(): return list(map(int, input().split())) def matrixPow(A, n, N, mod): B = np.identity(N, dtype = np.int) while n > 0: if n & 1 == 1: B = (A @ B) % mod A = (A @ A) % mod n >>= 1 return B #処理内容 def main(): N = int(input()) invP = 166666668 A = [1, 0, 0, 0, 0, 0, 0] for i in range(6): for j in range(i + 1, 7): A[j] += A[i] * invP A[j] %= con mat = np.full((6, 6), 0) for i in range(6): mat[0, i] = invP for i in range(1, 6): mat[i, i - 1] = 1 B = matrixPow(mat, N - 1, 6, con) b = np.full((6, 1), 0) for i in range(6): b[-1 - i, 0] = A[i + 1] ans = ((B @ b)[-1, 0]) % con print(ans) if __name__ == '__main__': main()