#P9249. [集训队互测 2018] 完美的旅行

    ID: 10064 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>数学图论2018集训队互测多项式矩阵加速生成函数

[集训队互测 2018] 完美的旅行

Problem Description

Xiao A has a graph with nn vertices, numbered from 00 to n1n-1. From vertex ii to vertex jj, there are Ai,jA_{i,j} directed edges. Self-loops may exist.

Now Xiao A is going to take several trips on the graph. In each trip, he chooses any starting point, walks at least one step, and ends at any destination point. Define the enjoyment value of a trip as the bitwise AND of the indices of the starting point and the ending point.

Curious Xiao B wants to know: for all x[1,m]x \in [1,m] and y[0,n)y \in [0,n), the number of ways such that Xiao A takes several trips, walks a total of xx steps, and the bitwise AND of the enjoyment values of all trips equals yy.

Two ways are different if and only if the number of trips is different, or some trip is not exactly the same.

To avoid outputting too much, you only need to output the bitwise XOR of these n×mn \times m numbers after taking them modulo 998244353998244353.

For convenience, it is guaranteed that nn is a power of 22.

Input Format

The first line contains two integers n,mn,m.

Then follows an n×nn \times n matrix. The number in row ii and column jj represents the number of directed edges from vertex i1i-1 to vertex j1j-1.

Output Format

Output one integer, representing the bitwise XOR value of the n×mn \times m answers after taking them modulo 998244353998244353.

2 3
1 2
3 4
1770

Hint

Sample Explanation

For walking 11 step, the numbers of ways with enjoyment-value bitwise AND =0,1= 0,1 are 6,46,4, respectively.

For walking 22 steps, they are 116,38116,38, respectively.

For walking 33 steps, they are 2012,3582012,358, respectively.

The XOR value is 17701770.

Constraints

For all testdata, 2n642 \leq n \leq 64, 1m200001 \leq m \leq 20000, 0Ai,j<9982443530 \leq A_{i,j} < 998244353, and it is guaranteed that nn is a power of 22.

Subtask ID Score nn \leq mm \leq Special Constraints
11 1515 1616 20002000
22 3232 1000010000
33 3535 6464 2000020000 Ai,j=ijA_{i,j}=i\otimes j, where \otimes denotes the bitwise XOR operation
44

Translated by ChatGPT 5