MOD = 10 ** 9 + 7 MEMO = {0 => 1} def pow_10_mod(e) return 1 if e.zero? return 10 if e == 1 MEMO[e] ||= (pow_10_mod(e - e / 2) * pow_10_mod(e / 2)) % MOD end def e_mod(n) (4 * pow_10_mod(n) - 1) / 3 end N = gets.to_i puts e_mod(N)