#include using namespace std; const int mod = 666013; const int nmax = 2e5; int fact[nmax + 1], inv[nmax + 1]; int d2[nmax + 1][ 2 ]; int lgput (int b, int p) { int ans = 1; while (p > 0) { if (p & 1) { ans = (1LL * ans * b) % mod; } p /= 2; b = (1LL * b * b) % mod; } return ans; } inline int C (int x, int y) { return ((1LL * fact[ x ] * inv[ y ]) % mod * inv[x - y]) % mod; } int main() { int n, m; cin >> n >> m; fact[ 0 ] = 1; for (int i = 1; i <= nmax; ++ i) { fact[ i ] = (1LL * fact[i - 1] * i) % mod; } for (int i = 0; i <= nmax; ++ i) { inv[ i ] = lgput(fact[ i ], mod - 2); } int ans = 0; if (n >= m) { for (int i = 0; i < m; ++ i) { int x = 1LL * C(m, i) * lgput(m - i, n) % mod; if (i % 2 == 0) { ans += x; } else { ans += mod - x; } if (ans >= mod) ans -= mod; } d2[ 0 ][ 1 ] = 1; for (int i = 1; i <= m; ++ i) { d2[ i ][ 0 ] = (1LL * d2[i - 1][ 1 ] * i) % mod; d2[ i ][ 1 ] = (1LL * d2[i - 1][ 1 ] * (i - 1) + d2[i - 1][ 0 ]) % mod; } } cout << (1LL * ans * d2[ m ][ 1 ]) % mod << "\n"; return 0; }