#include <bits/stdc++.h>

using namespace std;
const int c=5002;
long long n, m, sum, mod=998244353;
long long po[c][c];
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    for (int i=0; i<=m; i++) {
        po[i][0]=1;
    }
    for (int i=0; i<=m; i++) {
        for (int j=1; j<=n; j++) {
            po[i][j]=po[i][j-1]*i%mod;
        }
    }
    sum=po[m][n]*n%mod;
    for (int i=1; i<n; i++) {
        for (int j=1; j<=m; j++) {
            sum-=(n-i)*po[m][n-i-1]%mod*po[m-j][i-1]%mod;
        }
    }
    sum%=mod;
    if (sum<0) {
        sum+=mod;
    }
    cout << sum << "\n";
    return 0;
}

#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<vector<int>> Graph;
typedef vector<string> Grid;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chMAX(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}

//#define DEBUG

//declaration area
const ll int_inf = 1LL << 30;
const ll INF = 1LL << 60;
const ll MOD = 998244353;
//struct area

//function area
ll pow(ll x, ll n, ll MOD){
    ll ret = 1;
    while(n > 0){
        if(n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}
//main area
int main(){
    ll n, m;
    cin >> n >> m;
    cout << ((pow(10,n,m*m))-(pow(10,n,m)))/m << endl;
}
/*



*/