|
||||||||||
Hello World 3 Pro MaxTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 266 Accepted Submission(s): 111 Problem Description Once upon a time, Markyyz invented a problem named "Hello World". Later, Markyyz invented a problem named "Hello World 2", which is a harder version of "Hello World". Two thousand years later, SPY invented a problem named "Hello World 3", which is an even harder version of "Hello World". Now, SPY is inventing a problem named "Hello World 3 Pro Max", which is ... SPY has a string $S$ of length $n$ consisting of lowercase letters: $h,e,l,o,w,r,d$. The string is generated randomly in the following way: for each character in $S$, it is independently generated from the set $\{h,e,l,o,w,r,d\}$ with possibilities $p_1,p_2,...,p_7$. In other words, there is a probability of $p_1$ for the letter $h$, $p_2$ for the letter $e$, and so on. It is guaranteed that sum of $p_i$'s is equal to 1. Initially, each character of string $S$ is unknown. Then, SPY will perform $q$ operations of two types:
Input There are multiple tests. The first line of input consists a single integer $t$$(1\le t\le 10)$, representing the number of test cases. In each test case, the following lines provide the details: The first line consists a single integer $n$$(1\le n\le 5\times10^4)$, representing the length of string $S$. The second line contains 7 integers $P_1,P_2,...,P_7$$(1\le P_i\le 10^8)$. Let $P_t=P_1+P_2+...+P_7$ be the sum of these values. The possibilities of the letters are defined as $p_i=\frac{P_i}{P_t}$. The third line contains a single integer $q$$(1\le q\le 5\times10^4)$, representing the number of operations. The next $q$ lines describe the operations, each line specifying the type and parameters of the operation. It is guaranteed that sum of $n$ in all test cases will not exceed $5\times10^4$, sum of $q$ in all test cases will not exceed $5\times10^4$. Output After every operation of Type 2, output the expected number on a single line, modulo $10^9+7$. Sample Input
Sample Output
Source | ||||||||||
|