MOD = 10**9+7 def mat_dot(one, two, mod): return [[sum([(one[i][k]*two[k][j])%mod for k in range(max(len(two), len(one[0])))])%mod for j in range(len(two[0]))] for i in range(len(one))] def mat_pow(mat, exp, mod): size = len(mat) res = [[0 for _ in range(size)] for _ in range(size)] for i in range(size): res[i][i] = 1 cnt = 0 while (1<>cnt)&1: res = mat_dot(res, mat, mod) mat = mat_dot(mat, mat, mod) cnt += 1 return res n = int(input()) s = 166666668 p = [1, s] for _ in range(4): p.append((p[-1] * 7 * s) % MOD) if n < 6: print(p[n]) else: mat = [ [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], [s, s, s, s, s, s] ] res = mat_pow(mat, n-5, MOD) ans = 0 for i in range(6): ans += p[i] * res[5][i] ans %= MOD print(ans)