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;

namespace abc178_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();

      var mod = new Mod((int)1e9 + 7);

      if (N == 1)
      {
        Console.WriteLine(0);
        return;
      }

      if (N == 2)
      {
        Console.WriteLine(2);
        return;
      }

      var ans = mod.Sum(mod.Pow(10, N), mod.Mul(mod.Pow(9, N), -2), mod.Pow(8, N));

      Console.WriteLine(ans);
    }
  }

  class Mod
  {
    public int N { get; }
    private readonly List<long> fac = new List<long>() { 1, 1 };
    private readonly List<long> inv = new List<long>() { 0, 1 };
    private readonly List<long> facInv = new List<long>() { 1, 1 };

    public Mod(int n) { N = n; }

    public long Add(long a, long b) => (a % N + b % N + N) % N;
    public long Sub(long a, long b) => Add(a, -b);
    public long Mul(long a, long b) => (a % N * b % N + N) % N;
    public long Div(long a, long b) => Mul(a, Inv(b));

    public long Sum(params long[] args) => args.Aggregate(Add);

    public long Inv(long a)
    {
      if (a < inv.Count) return inv[(int)a];
      long b = N, x = 1, y = 0, tmp;
      while (b != 0)
      {
        var q = a / b;
        tmp = y;
        y = x - q * y;
        x = tmp;
        tmp = b;
        b = a - q * b;
        a = tmp;
      }
      return (x % N + N) % N;
    }

    public long Pow(long a, long n)
    {
      var result = 1L;
      while (n > 0)
      {
        if ((n & 1) == 1) result = Mul(result, a);
        a = Mul(a, a);
        n >>= 1;
      }
      return result;
    }

    public void InitSeq(int n)
    {
      for (var i = fac.Count; i <= n; i++)
      {
        fac.Add(fac[i - 1] * i % N);
        inv.Add(N - inv[N % i] * (N / i) % N);
        facInv.Add(facInv[i - 1] * inv[i] % N);
      }
    }

    public long Fac(int n)
    {
      InitSeq(n);
      return fac[n];
    }

    public long Per(int n, int k)
    {
      if (n < k || n < 0 || k < 0) return 0;
      InitSeq(n);
      return fac[n] * facInv[n - k] % N;
    }

    public long Com(int n, int k)
    {
      if (n < k || n < 0 || k < 0) return 0;
      InitSeq(n);
      return fac[n] * (facInv[k] * facInv[n - k] % N) % N;
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}