def mod_repeated_number(n: int, k: int, mod: int) -> int: """n を k 回繰り返した整数を mod で割った余りを求める""" nd = len(str(n)) def rec(k: int): if k == 1: return n k2 = k // 2 x = rec(k2) r = ((x * pow(10, k2 * nd, mod) % mod) + x) % mod if k % 2 == 1: r = ((r * pow(10, nd, mod) % mod) + n) % mod return r if n == 0: return 0 return rec(k) MOD = 10 ** 9 + 7 N = int(input()) ans = pow(10, N, MOD) + mod_repeated_number(3, N, MOD) ans %= MOD print(ans)