#P10308. 「Cfz Round 2」Osmanthus
「Cfz Round 2」Osmanthus
Problem Description
You are given a sequence of length .
We define one operation as: simultaneously replace every element in the sequence with (i.e., the XOR sum from to ), where denotes bitwise XOR, i.e., ^ in C++.
There are ordered modifications. Each modification gives two integers , meaning to change the value of to . These modifications are not independent; each modification affects all subsequent modifications.
After each modification, you need to find the smallest positive integer such that after performing the operation times, the sequence becomes the same as the sequence before the operations. It can be proven that such a positive integer always exists.
Since the answer may be very large, you only need to output the result modulo .
Input Format
The first line contains two integers .
The second line contains integers, representing the given sequence .
The next lines each contain two integers , representing one modification.
Output Format
Output lines. On the -th line, output one integer: after the -th modification, the smallest positive integer that satisfies the requirement, modulo .
3 3
3 1 0
2 2
1 0
2 0
4
2
1
Hint
"Sample Explanation #1"
After the 1st modification, the sequence is . After performing the operation 1 time, the sequence becomes . After 2 times, it becomes . After 3 times, it becomes . After 4 times, it becomes . Therefore, the smallest required positive integer is .
Constraints
For all data, , , .
Only if you pass all test points of this problem can you get the score for this problem.
Translated by ChatGPT 5