#P9853. Count

Count

Count

Problem Description

You are given three positive integers nn, mm, and kk. Your task is to calculate the total number of sequences AA of length nn that satisfy the following conditions:

  1. All elements of AA are integers from 11 to mm(inclusive).
  2. Let AiA_i be the ii-th element of sequence AA. For all positive integers ii not exceeding kk, it is satisfied that Ai=Ank+iA_i = A_{n-k+i}. Calculate the total number of such sequences AA that satisfy the conditions and output the result modulo 998244353.

Input

The first line contains an integer TT1000T (T\leq 1000), representing the number of test cases. Each of the next TT lines contains three integers nn, mm, and k1n,m,k1018,knk(1 \leq n,m,k \leq 10^{18} , k \leq n), representing the parameters for one test case.

Output

For each test case, output an integer representing the answer.

Sample Input

1
11 2 1

Sample Output

1024

Source

2023“钉耙编程”中国大学生算法设计超级联赛(6)