There are N power generators and M appliances. The ith generator produces a power of A_i. The jth appliance is connected to a set of generator S_j and gets its energy from them. Let C_j be the number of generators in S_j.
The energy obtained by each appliance can be calculated with the following formula.
∑_1≤a≤b≤C_jA_S_j\[a]⋅A_S_j\[b]
For example, let’s say an appliance gets its energy from 4 generators and each of them produces 10, 5, 20, and 5 of power, respectively. The energy obtained by this appliance is 10⋅5+10⋅20+10⋅5+5⋅20+5⋅5+20⋅5=50+200+50+100+25+100=525.
For the next Q days, you will perform one of these two operations.
For each operation of the second type, output the energy obtained by the jth appliance.
Input begins with a line containing two integers: N M (1≤N,M≤1000˜00) representing the number of power generators and the number of appliances, respectively. The next line contains N integers: A_i (1≤A_i≤100˜00) representing the power produced by the generators initially. The next M lines each begins with an integer C_j (1≤C_j≤N) representing the number of generators that are connected to the jth appliance, followed by C_j integers: S_j\[k] (1≤S_j\[k]≤N) representing the connected generators. For all j, the generators in S_j are guaranteed to be unique. The sum of all C_j is not more than 2000˜00.
The next line contains an integer: Q (1≤Q≤1000˜00) representing the number of days. The next Q lines each contains one of the following input format representing the operation you should perform.
There will be at least one operation of the second type.
For each operation of the second type in the same order as input, output in a line an integer representing the energy obtained by the jth appliance.