import sys def I(): return int(sys.stdin.readline().rstrip()) def matrix_multiplication_mod(A,B,p): l = len(A) m = len(B) n = len(B[0]) C = [[0]*n for _ in range(l)] for i in range(l): for j in range(n): C[i][j] = sum((A[i][k]*B[k][j]) % p for k in range(m)) % p return C def matrix_power_mod(A,n,p): l = len(A) C = [[0] * l for _ in range(l)] for i in range(l): C[i][i] = 1 while n > 0: if n % 2 == 1: C = matrix_multiplication_mod(C,A,p) A = matrix_multiplication_mod(A,A,p) n >>= 1 return C N = I() mod = 10**9+7 a = pow(6,mod-2,mod) P = [1,a] for _ in range(4): P.append((P[-1]*7*a) % mod) if N <= 5: print(P[N]) exit() A = [[a,a,a,a,a,a],[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,0,]] X = matrix_power_mod(A,N-5,mod)[0] P.reverse() ans = 0 for x,p in zip(X,P): ans += x*p ans %= mod print(ans)