#D. Great Sequences

    Type: Default 1000ms 256MiB

Great Sequences

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Great Sequences

Problem Statement

Farmer John's farm is home to NN (1N30)(1≤N≤30) cows, each identified by a unique name represented as a positive integer from 11 to NN.

John is interested in creating pairs of sequences, each of length MM (1M109)(1≤M≤10^9). Each sequence is built with the cows' names. A pair of sequences, $(S, T) = ((S_1, S_2, \dots , S_M), (T_1, T_2, \dots , T_M))$, earns the title of a 'beautiful pair' if it satisfies the following condition:

  • There exists a binary sequence X=(X1,X2,,XN)X = (X_1, X_2, \dots , X_N) of length NN. For this sequence, at every index ii from 11 to MM, the SithS_i^{th} element of XX is different from the TithT_i^{th} element of XX.

With N2MN^{2M} possible pairs of sequences of length MM using the cows' names, John is curious about the number of 'beautiful pairs' he can create.

Given the large number of possible sequences, he wants the answer modulo 998244353998244353.

INPUT FORMAT (input arrives from the terminal / stdin):

The first line contains two integers NN and MM.

OUTPUT FORMAT (print output to the terminal / stdout):

Output a single integer: the number of "beautiful pairs" of sequences, modulo 998244353998244353. The sequences should be of length MM and consist of positive integers no greater than NN.

SAMPLE INPUT 1:

3 2

SAMPLE OUTPUT 1:

36

For example, if sequence AA is (1,2)(1, 2), and sequence B is (2,3)(2, 3), then (A,B)(A, B) is a beautiful pair of sequences. Indeed, if we set XX to be (0,1,0)(0, 1, 0), then XX is a binary sequence of length NN consisting of 00 and 11 that satisfies the condition where the SithS_i^{th} element of XX is different from the TithT_i^{th} element of XX for every index ii from 11 to MM. Thus, (A,B)(A, B) satisfies the condition of being a beautiful pair of sequences.

There are a total of 3636 beautiful pairs of sequences, so we print this number.

SAMPLE INPUT 2:

20 231104

SAMPLE OUTPUT 2:

966200489

SCORING:

  • Inputs 3-7: 1N,M41 \leq N, M \leq 4
  • Inputs 8-10: 1N4,1M1071 \leq N \leq 4, 1 \leq M \leq 10^7
  • Inputs 11-20: No additional constraints.

HFI Coding Club 2023 November Contest

Not Attended
Status
Done
Rule
IOI
Problem
4
Start at
2023-11-16 18:45
End at
2023-11-16 20:45
Duration
2 hour(s)
Host
Partic.
21