#P1861E. Non-Intersecting Subpermutations

    ID: 10043 Type: RemoteJudge 2000ms 512MiB Tried: 8 Accepted: 3 Difficulty: 10 Uploaded By: Tags>combinatoricsdpimplementationmath

Non-Intersecting Subpermutations

Description

You are given two integers nn and kk.

For an array of length nn, let's define its cost as the maximum number of contiguous subarrays of this array that can be chosen so that:

  • each element belongs to at most one subarray;
  • the length of each subarray is exactly kk;
  • each subarray contains each integer from 11 to kk exactly once.

For example, if n=10n = 10, k=3k = 3 and the array is [1,2,1,3,2,3,2,3,1,3][1, 2, 1, 3, 2, 3, 2, 3, 1, 3], its cost is 22 because, for example, we can choose the subarrays from the 22-nd element to the 44-th element and from the 77-th element to the 99-th element, and we can show that it's impossible to choose more than 22 subarrays.

Calculate the sum of costs over all arrays of length nn consisting of integers from 11 to kk, and print it modulo 998244353998244353.

The only line of the input contains two integers nn and kk (2kn40002 \le k \le n \le 4000).

Print one integer — the sum of costs of all arrays of length nn consisting of integers from 11 to kk taken modulo 998244353998244353.

Input

The only line of the input contains two integers nn and kk (2kn40002 \le k \le n \le 4000).

Output

Print one integer — the sum of costs of all arrays of length nn consisting of integers from 11 to kk taken modulo 998244353998244353.

Sample Input 1

10 3

Sample Output 1

71712

Sample Input 2

2 2

Sample Output 2

2

Sample Input 3

1337 42

Sample Output 3

524933698