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++ (GCC 9.2.1) (judge verdict: Accepted)



#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second

using namespace __gnu_pbds;
using namespace std;
const int mod = 1e9+7;
//const int mod=998'244'353;
//const int mod=1e9+9;
const int INF=4e18+10;
// const int INF = 4e18 + 10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) \
    int n;      \
cin >> n;
#define readv(x, n)   \
    vector<int> x(n); \
for (auto &i : x) \
cin >> i;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template <typename T1, typename T2>
void set_min(T1 &a, T2 b){
    a = min(a, (T1)b);
}
/* template <typename T1, typename T2> */
bool sort_by_sec(pair<int, int> a, pair<int,int> b)
{
    return make_pair(a.se, a.fi)<make_pair(b.se,b.fi);
}

int multiply(int a, int b, int in_mod) { return (int)(1LL*a * b % in_mod );}
int mult_identity(int a) { return 1; }

int mod_inv(int q, int in_mod);

// const int mod = 998244353;
// const int root  = 15311432;
// const int root_pw = 1<<23;
// const int root_1 = mod_inv(root, mod);

//const int mod = 7340033;
//const int root  = 5;
//const int root_pw = 1<<20;
//const int root_1 = 4404020;

vector<int >multiply(const vector<int>& a, const vector<int>& b,int mod);
vector<int> mult_identity(vector<int> a)
{
    return {1};
}

vector<int> operator%(vector<int> a, int mod)
{
    return a;
}





auto power(auto a, int b, int in_mod)
{

    // if(b>=in_mod)
    //     b%=in_mod-1;
    auto prod = mult_identity(a);
    auto mult = a % in_mod;
    while (b != 0)
    {
        if (b % 2)
        {
            prod = multiply(prod, mult, in_mod);
        }
        mult = multiply(mult, mult, in_mod);
        b /= 2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod - 2, in_mod);
}
void solve()
{
    int n;
    cin>>n;
    int ways = power(10,n, mod);
    ways = (ways -2* power(9,n,mod) + mod)%mod;
    ways = ((ways + power(8,n,mod)%mod)%mod + mod)%mod;
    cout<<ways<<endl;
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cerr.tie(NULL);
     #ifndef ONLINE_JUDGE
         if (fopen("INPUT.txt", "r"))
         {
             freopen("INPUT.txt", "r", stdin);
             freopen("OUTPUT.txt", "w", stdout);
         }
     #endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t = 1;
    /* cin >> t; */

    for (int test = 1; test <= t; test++)
    {
        /* cout<<"Case #"<<test<<": "; */
        solve();
        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}