MOD = 10 ** 9 + 7 N = int(input()) t = 3 ans = 1 d = 10 while N > 0: if N & 1: ans = (ans * d + t) % MOD t = (t * d + t) % MOD d = (d * d) % MOD N >>= 1 print(ans)