#P12375. Maximum MST Weight Sum

    ID: 14477 Type: Default 1000ms 256MiB

Maximum MST Weight Sum

Maximum MST Weight Sum

Given two positive integers n and m with m not exceeding the maximum number of edges in a simple undirected graph (and at least n-1 to ensure connectivity), your task is to construct a connected simple undirected graph having n vertices and m edges with distinct edge weights from 1 to m so that the weight sum of its minimum spanning tree (MST) is maximized.

You are free to choose the graph structure and also assign each weight arbitrarily to the edges, provided that no self-loops or multi-edges occur. Under these circumstances it can be proved that the maximum MST weight sum that can be enforced is \[ \frac{n(n-1)}{2}\mod 998244353, \] regardless of the value of m (as long as mn-1).

Output the maximum possible MST weight sum modulo 998244353.

inputFormat

The input consists of a single line containing two integers n and m (n-1m ≤ n(n-1)/2), where n is the number of vertices and m is the number of edges in the graph.

outputFormat

Output a single integer, the maximum possible sum of the MST's edge weights, taken modulo 998244353.

sample

3 3
3