Problem:
Score : 300 points

Problem Statement

How many integer sequences A_1,A_2,\ldots,A_N of length N satisfy all of the following conditions?

0 \leq A_i \leq 9

There exists some i such that A_i=0 holds.

There exists some i such that A_i=9 holds.

The answer can be very large, so output it modulo 10^9 + 7.

Constraints

1 \leq N \leq 10^6

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the answer modulo 10^9 + 7.

Sample Input 1

2

Sample Output 1

2

Two sequences \{0,9\} and \{9,0\} satisfy all conditions.

Sample Input 2

1

Sample Output 2

0

Sample Input 3

869121

Sample Output 3

2511445

Solution in Kotlin (1.3.71) (judge verdict: Accepted)

import java.io.BufferedReader
import java.io.BufferedWriter

fun main() = Case().exec(::solve)
//fun main() = TestExecutor.assert(testCase) { Case(it.r, it.w).exec(::solve) }

/** https://atcoder.jp/contests/abc178/tasks/abc178_c **/
fun solve(c: Case) {
    val n = c.long().toInt()
    var last = listOf(ModInt(8), ModInt(1), ModInt(1), ModInt(0))
    repeat(n - 1) {
        val next = listOf(
            last[0] * ModInt(8),
            last[0] + (last[1] * ModInt(9)),
            last[0] + (last[2] * ModInt(9)),
            last[1] + last[2] + (last[3] * ModInt(10))
        )
        last = next
    }
    c.println(last[3].v.toString())
}

class ModInt(var v: Long) {
    companion object {
        const val MOD = 1000000007L
    }

    override operator fun equals(other: Any?) = other != null && other is ModInt && v == other.v
    override fun hashCode() = v.hashCode()
    override fun toString() = "ModInt($v)"

    operator fun plus(o: ModInt): ModInt = ModInt(v).also { it += o }
    operator fun minus(o: ModInt): ModInt = ModInt(v).also { it -= o }
    operator fun times(o: ModInt): ModInt = ModInt(v).also { it *= o }
    operator fun div(o: ModInt): ModInt = ModInt(v).also { it /= o }

    operator fun plusAssign(o: ModInt) {
        v += o.v; if (v > MOD) v -= MOD
    }

    operator fun minusAssign(o: ModInt) {
        v -= o.v; if (v < 0) v += MOD
    }

    operator fun timesAssign(o: ModInt) {
        v = v * o.v % MOD
    }

    operator fun divAssign(o: ModInt) {
        v = v * o.v.inv() % MOD
    }

    fun inv(): ModInt {
        var (g, x, y, r) = listOf(MOD, 0L, 1L, v)
        while (r != 0L) {
            val q = g / r
            g %= r
            g = r.also { r = g }
            x -= q * y
            x = y.also { y = x }
        }
        return ModInt(if (x < 0) x + MOD else x)
    }
}

class Case(
    private val input: BufferedReader = System.`in`.bufferedReader(),
    private val out: BufferedWriter = System.out.bufferedWriter()
) {
    fun exec(fn: (Case) -> Unit) = input.use { out.use { execInThread(fn) } }
    private fun execInThread(fn: (Case) -> Unit) =
        Thread(null, { fn(this) }, "solve", 64 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }
            .apply { start() }.join()

    fun println(c: CharSequence?) = out.appendln(c)
    fun string(): String = input.readLine().trimEnd()
    fun long(): Long = input.readLine().toLong()
    fun intList(): List<Int> = input.readLine().split(" ").map { it.toInt() }
    fun longList(): List<Long> = input.readLine().split(" ").map { it.toLong() }
}