p = 1000000007 def solve(N): if N < 10: return int('1' + '3' * N) % p ans = (10 ** (N%9)) % p * pow(-7, (N//9), p) ans += (3 * 111111111 * 10 ** (N%9)) % p * (1 - pow(-7, (N//9), p)) * 125000001 ans += int('3' * (N%9)) return ans % p N = int(input()) print(solve(N))