#P10308. 「Cfz Round 2」Osmanthus

    ID: 11268 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>数学洛谷原创O2优化位运算洛谷月赛Ad-hoc

「Cfz Round 2」Osmanthus

Problem Description

You are given a sequence aa of length nn.

We define one operation as: simultaneously replace every element aia_i in the sequence aa with j=1iaj\bigoplus\limits_{j=1}^i a_j (i.e., the XOR sum from a1a_1 to aia_i), where \bigoplus denotes bitwise XOR, i.e., ^ in C++.

There are qq ordered modifications. Each modification gives two integers xi,pix_i, p_i, meaning to change the value of axia_{x_i} to pip_i. These modifications are not independent; each modification affects all subsequent modifications.

After each modification, you need to find the smallest positive integer tt such that after performing the operation tt times, the sequence aa becomes the same as the sequence aa before the operations. It can be proven that such a positive integer tt always exists.

Since the answer may be very large, you only need to output the result modulo (109+7)(10^9+7).

Input Format

The first line contains two integers n,qn, q.

The second line contains nn integers, representing the given sequence aa.

The next qq lines each contain two integers xi,pix_i, p_i, representing one modification.

Output Format

Output qq lines. On the ii-th line, output one integer: after the ii-th modification, the smallest positive integer tt that satisfies the requirement, modulo (109+7)(10^9+7).

3 3
3 1 0
2 2
1 0
2 0
4
2
1

Hint

"Sample Explanation #1"

After the 1st modification, the sequence aa is {3,2,0}\{3,2,0\}. After performing the operation 1 time, the sequence aa becomes {3,1,1}\{3,1,1\}. After 2 times, it becomes {3,2,3}\{3,2,3\}. After 3 times, it becomes {3,1,2}\{3,1,2\}. After 4 times, it becomes {3,2,0}\{3,2,0\}. Therefore, the smallest required positive integer tt is 44.

Constraints

For all data, 1n,q3×1051 \le n,q \le 3\times10^5, 0ai,pi1090 \le a_i,p_i \le 10^9, 1xin1 \le x_i \le n.

Only if you pass all test points of this problem can you get the score for this problem.

Translated by ChatGPT 5