#ZH202502. Another Day of Sun
Another Day of Sun
Description
'Cause morning rolls around, and it's another day of sun!
But as a sleep addict, Sean spends lots of hours sleeping, and thus, he can't even remember which day it is when he wakes up.
So starting from someday, he started taking notes: when he wakes up, he writes a number about whether there's sunlight outside. If there is, he will write a on it; otherwise, he will write a . And after taking notes, without enough time for sunlight to fade or for moonlight to dim, he falls asleep again. We assume that every time Sean wakes up, he sees either the sunlight or the moonlight, but not both.
So the notes actually form an array of length nn : $[a_1, a_2, \dots, a_n] (\forall 1 \leq i \leq n, 0 \leq a_i \leq 1)$, where represents the -th number Sean wrote.
However, as time goes on, some numbers written become ambiguous and are just impossible to identify, and you can't really tell whether it is a or a . So if there are numbers that you can't identify, there can be different arrays.
For each array, you can calculate the minimum number of days on which Sean sees the sunlight at least once that is consistent with the notes the array represents. If you add the results of different arrays together, what will you get? As the answer can get quite enormous, output it modulo .
Note that we only care about the minimum number of days when the notes with number are taken.
Input
Each test contains multiple test cases. The first line contains the number of test cases .
Each test case consists of two lines.
The first line contains one integer , the number of notes.
The second line contains nn integers , each number written on the note. The number is unknown if and only if .
It is guaranteed that over all test cases in one test will not exceed .
Output
For each test case, output one integer: the sum of results modulo .
Example
3
3
1 0 1
3
0 0 0
3
1 -1 1
2
0
3
In the first test case, when Sean takes the first note and the third note, the sun he has seen must have been of different days.
In the second test case, Sean never sees the sun, so the answer is .
In the third test case, the array can be or . If the array is , the notes can be taken in the same day, so Sean could have seen the daylight of the same day, and the result is . If the array is , the first and third notes must have been taken in different days, so there are at least days of sun that Sean has seen. So the answer is .