You have an initially empty string , and you're given queries of the form:
, is either or and is an integer between and 10^9.
First permanently add the character to the end of , and then calculate the probability of the last character in F(s,x) being a .
Calculating F(s,x) of a string and an integer is done by the following process:
Let be the size of the string and let be an empty string, then for each starting from going up to infinity as long as doesn't have consecutive equal characters:
If i \le sz, add s_i to the end of , otherwise add either or randomly to the end of .
F(s,x) is equal to the resulting string .
The answer can be represented as a rational number \frac{p}{q}. Print p\cdot q^{-1} mod 10^9+7.
The first line of the input contains an integer (1 \le t \le 2\cdot10^5) the number of testcases.
The description for the test cases follows.
The first line of each test case contains a single integer (1 \le q \le 2\cdot10^5) the number of queries.
The next lines are of the form:
( , 1 \le x \le 10^8)
It is guaranteed that the sum of over all test cases does not exceed 2\cdot10^5.
For each query, output the probability modulo 10^9+7.
Example 1
For the third query of the first test case, s = 101 and x = 2:
is initially empty and sz=3, now we follow the explained process for each starting from going up to infinity:
For i=1:
Since 1 \le sz=3, we add s_1=1 to the end of .
For i=2:
Since 2 \le sz=3, we add s_2=0 to the end of .
For i=3:
Since 3 \le sz=3, we add s_3=1 to the end of .
Now h=101, and the probability of the last character in being a once the process stops is equal to \frac{2}{3}, and \frac{2}{3} mod 10^9+7 .
For the third query of the second test case, s = 001 and x = 2:
is initially empty and sz=3, now we follow the explained process for each starting from going up to infinity:
For i=1:
Since 1 \le sz=3, we add s_1=0 to the end of .
For i=2:
Since 2 \le sz=3, we add s_2=0 to the end of .
The process stops after i=2 because has x=2 consecutive characters. so the probability of the last character in being a is equal to .
Subtask ( points): x=1 over all queries
Subtask ( points): x=2 over all queries
Subtask ( points): c=1 over all queries
Subtask ( points): (\sum q \le 1000)
Subtask ( points): x=3 over all queries
Subtask ( points): no additional constraints