# coding: utf-8 # Your code here! MOD=10**9+7 def matmul(A,B,mod): # A,B: 行列 res = [[0]*len(B[0]) for _ in [None]*len(A)] for i, resi in enumerate(res): for k, aik in enumerate(A[i]): for j,bkj in enumerate(B[k]): resi[j] += aik*bkj resi[j] %= mod return res def matpow(A,p,M): #A^p mod M if p%2: return matmul(A, matpow(A,p-1,M), M) elif p > 0: b = matpow(A,p//2,M) return matmul(b,b,M) else: return [[1 if i == j else 0 for j in range(len(A))] for i in range(len(A))] # coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline n, = map(int,read().split()) s = pow(6,MOD-2,MOD) A = [[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]] v = matmul(matpow(A,n,MOD),[[0],[0],[0],[0],[0],[1]],MOD) print(v[5][0])