Under construction

Still being built. Things may change

Classical Summation Problem

Time limit2sMemory limit1024 MB

Summary
Sum the smallest optimal city (the median of the friends' positions) over all n^k placements of k friends on a line of n cities, modulo 998244353.
Level

Medium7 of 10

Topics
Combinatorics, Math
Solved
No attempts yet

Problem

The Republic of Never has nn cities and n−1n-1 roads. The cities are numbered from 11 to nn. The roads are numbered from 11 to n−1n-1, and road ii connects cities ii and i+1i + 1. Every road can be traversed in both directions. The distance d(u,v)=∣u−v∣d(u, v) = |u - v| is the smallest number of roads one needs to use to move from city uu to city vv.

kk friends want to meet. The ii-th friend lives in city aia_i. The friends choose a city vv that minimizes ∑i=1kd(v,ai)\sum_{i=1}^k d(v, a_i). If several cities achieve the minimum, they choose the one with the smallest number.

You know only the number of friends, not the cities where they live. Each friend can live in any of the nn cities, so there are nkn^k possible cases. Find the sum of the numbers of the cities the friends choose over all nkn^k cases.

Input

The only line contains two integers nn and kk, the number of cities and the number of friends (2≤n,k≤1062 \le n, k \le 10^6).

Output

Print the sum over all nkn^k cases, modulo 998 244 353998\,244\,353.

Hint

In the first case, there are 3 cities and 2 friends, so there are 32=93^2 = 9 cases. If either friend lives in city 1, the friends choose city 1, which happens in 5 cases. Otherwise, if either friend lives in city 2, they choose city 2, which happens in 3 cases. In the remaining case, both friends live in city 3, and they choose city 3. The total is 5⋅1+3⋅2+1⋅3=145 \cdot 1 + 3 \cdot 2 + 1 \cdot 3 = 14.

Examples2

  1. Example 1

    Input
    3 2
    
    Expected output
    14
    
  2. Example 2

    Input
    5 3
    
    Expected output
    375