#include <bits/stdc++.h>
using namespace std;

const int Mod = 666013;

int N,M;
int dp[100001];
int dps[100001];
int fact[100001];

int log_put(int n,int p)
{
    if (p == 0) return 1;
    if (p&1) return 1LL * n * log_put(1LL * n * n % Mod,p/2) % Mod;
    return log_put(1LL * n * n % Mod,p/2);
}

int main()
{
    //reopen("input","r",stdin);

    cin >> N >> M;
    if (N < M || M == 1)
    {
        cout << 0;
        return 0;
    }

    dp[1] = 0;
    dp[2] = 1;
    dp[3] = 2;
    for (int i = 4; i <= M; i++)
        dp[i] = 1LL * (i-1) * (dp[i-1] + dp[i-2]) % Mod;

    fact[0] = 1;
    for (int i = 1; i <= N; i++)
        fact[i] = 1LL * i * fact[i-1] % Mod;

    int A = dp[M];
    int d = log_put(fact[M],Mod-2);
    int sm = 0;
    for (int i = 0, j = 1; i <= M; i++, j = -j) {
        int add = 1LL * fact[M] * log_put(fact[M-i],Mod-2) % Mod * log_put(fact[i],Mod-2) % Mod * log_put(M-i,N) % Mod;
        sm += j * add;
        sm += Mod;
        sm %= Mod;
    }
    int B = 1LL * sm * d % Mod;
    cout << 1LL * A * B % Mod * fact[M] % Mod;
}