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 C# (.NET Core 3.1.201) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("869121");
            //2511445
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        checked {
            List<string> InputList = GetInputList();

            int N = int.Parse(InputList[0]);

            const long Hou = 1000000000 + 7;

            long Answer = DeriveModPow(10, N, Hou);
            Answer -= 2 * DeriveModPow(9, N, Hou);
            Answer %= Hou;
            if (Answer < 0) Answer += Hou;

            Answer += DeriveModPow(8, N, Hou);
            Answer %= Hou;

            Console.WriteLine(Answer);
        }
    }

    //繰り返し2乗法で、(NのP乗) Mod Mを求める
    static long DeriveModPow(long pN, long pP, long pM)
    {
        checked {
            long CurrJyousuu = pN % pM;
            long CurrShisuu = 1;
            long WillReturn = 1;

            while (true) {
                //対象ビットが立っている場合
                if ((pP & CurrShisuu) > 0) {
                    WillReturn = (WillReturn * CurrJyousuu) % pM;
                }

                CurrShisuu *= 2;
                if (CurrShisuu > pP) return WillReturn;
                CurrJyousuu = (CurrJyousuu * CurrJyousuu) % pM;
            }
        }
    }
}