def mod_repeated_number(n: int, k: int, mod: int) -> int: """n を k 回繰り返した整数を mod で割った余りを求める""" nd = len(str(n)) def pow10(exp: int) -> int: return pow(10, exp, mod) def rec(k: int): if k == 1: return n k2 = k // 2 x = rec(k2) r = ((x * pow10(k2 * nd) % mod) + x) % mod if k % 2 == 1: r = ((r * pow10(nd) % 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)