#P7948. Fall with Soldiers

Fall with Soldiers

Fall with Soldiers

Problem Description

Fall is playing a game about a war. There are nn soldiers standing in a line. Some of them belong to the player, while others belong to the enemy. Due to the spies, the belonging of some of them is unknown. Now, as an artillery, the player may win this game under the following rules after identifying the belonging of each soldier: Step 1: Choose a soldier which belongs to the player. There should be exactly two soldiers next to the chosen one, which means the chosen soldier should be neither at the beginning nor at the end of the line. Step 2: Kill the soldiers next to the chosen one (the chosen one will remain alive). Step 3: Repeat step 1 and step 2 until all the soldiers left belong to the same side (the player or the enemy). The player wins if all the soldiers left belong to the player. Fall, as the player, wants to know the number of ways to identify the belonging of each soldier so that he can win. However, soldiers may change their state (the player's troops, the enemies, or unknown). You need to calculate the answers after every change.

Input

The input consists of multiple test cases. The first line contains an integer TT (1T111 \leq T \leq 11) -- the number of test cases. For each test case: In the first line, there are two integer n,qn,q (1n,q2×1051 \leq n,q \leq 2 \times 10^5, nn is odd ), which are the number of soldiers and the number of operations. In the second line, there is a string ss of length nn, which represents the initial soldier state. If sis_i is '1', the soldier belongs to you. If sis_i is '0', the soldier belongs to your enemy. If sis_i is '?', the belonging of this soldier is unknown. In the next qq lines, each contains an integer pp (1ps1 \leq p \leq |s|) and a charactor cc, which means change sps_p to cc. It is guaranteed that the sum of qq over all test cases will not exceed 10610^6, si,c{0,1,?}s_i,c \in \{'0','1','?'\}

Output

For each test case, output the initial answer in a single line. Then output qq answers in qq lines, which are your answers after each change. All the answers should be output modulo 109+710^9+7.

Sample Input

6

5 1

01000

1 1

5 1

00000

3 1

15 4

1100????????111

8 ?

1 0

4 1

11 ?

15 4

0????000?0???0?

6 0

10 0

1 ?

10 ?

15 2

???????0?0???0?

4 0

1 0

15 2

00000000?0???0?

4 ?

4 ?

Sample Output

0

0

0

1

247

247

247

253

253

368

368

368

736

1664

3616

1760

880

0

24

24

Source

2021“MINIEYE杯”中国大学生算法设计超级联赛(7)