#P9249. [集训队互测 2018] 完美的旅行
[集训队互测 2018] 完美的旅行
Problem Description
Xiao A has a graph with vertices, numbered from to . From vertex to vertex , there are 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 and , the number of ways such that Xiao A takes several trips, walks a total of steps, and the bitwise AND of the enjoyment values of all trips equals .
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 numbers after taking them modulo .
For convenience, it is guaranteed that is a power of .
Input Format
The first line contains two integers .
Then follows an matrix. The number in row and column represents the number of directed edges from vertex to vertex .
Output Format
Output one integer, representing the bitwise XOR value of the answers after taking them modulo .
2 3
1 2
3 4
1770
Hint
Sample Explanation
For walking step, the numbers of ways with enjoyment-value bitwise AND are , respectively.
For walking steps, they are , respectively.
For walking steps, they are , respectively.
The XOR value is .
Constraints
For all testdata, , , , and it is guaranteed that is a power of .
| Subtask ID | Score | Special Constraints | ||
|---|---|---|---|---|
| , where denotes the bitwise XOR operation | ||||
Translated by ChatGPT 5