#P8110. [Cnoi2021] 矩阵

[Cnoi2021] 矩阵

Description

Given two sequences of length nn, {an}\{a_n\} and {bn}\{b_n\}, and an integer kk.

Let matrix AA satisfy Aij=ai×bjA_{ij}=a_i\times b_j. Find the sum of all elements in AkA^k modulo 998244353998244353.

Input Format

The first line contains two integers nn and kk.

The second line contains nn integers separated by spaces, representing {an}\{a_n\}.

The third line contains nn integers separated by spaces, representing {bn}\{b_n\}.

Output Format

One line containing one integer, representing the sum of all elements in AkA^k modulo 998244353998244353.

3 0
1 2 3
4 5 6
3
3 3
1 2 3
4 5 6
92160

Hint

Constraints

For 100%100\% of the testdata, it is guaranteed that 1n1051 \le n \le 10^5, 0k<9982443530 \le k < 998244353, and ai,bi109|a_i|, |b_i| \le 10^9.

Subtasks

Subtask 1 (10 points): n,k50n, k \le 50.

Subtask 2 (20 points): n100n \le 100.

Subtask 3 (20 points): n1000n \le 1000.

Subtask 4 (50 points): no special constraints.

Notes

For the definition of matrix multiplication, refer to the Baidu Baike page.

In this problem, A0A^0 denotes the identity matrix.

Translated by ChatGPT 5