def f(a,b,n): if n==0: return 1 if n%2: return (f(a,b,n-1)*a+b)%MOD else: return f(a*a%MOD,(a+1)*b%MOD,n//2) MOD = 10**9+7 n = int(input()) print(f(10,3,n))