import java.util.*; public class Main { static final int MOD = 1000000007; public static void main (String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long[] allThrees = new long[63]; allThrees[0] = 3; for (int i = 1; i < 63; i++) { allThrees[i] = allThrees[i - 1] * (1 + pow(10, 1L << (i - 1))) % MOD; } long ans = pow(10, n); int add = 0; for (int i = 0; i < 63 && n > 0; i++) { if (n % 2 == 1) { ans += allThrees[i] * pow(10, add) % MOD; ans %= MOD; add += i + 1; } n /= 2; } System.out.println(ans); } static long pow(long x, long p) { if (p == 0) { return 1; } else if (p % 2 == 0) { return pow(x * x % MOD, p / 2); } else { return pow(x, p - 1) * x % MOD; } } }