#ds605. 序列维护
序列维护
Sequence Maintenance
Problem Description
You are to maintain sequences , which are initially all empty. Then you must support operations:
1 x y: append the number to the end of sequence . The indices of every sequence start from .2 z: for every non-empty sequence , compute the element , and output the sum of all such elements, where denotes the number of elements in sequence .
Input Format
The first line contains two integers ($1 \leq n \leq 2 \times 10^5,\ 1 \leq q \leq 4 \times 10^5$).
The next lines each describe one operation. It is guaranteed that .
Output Format
For each query operation, output one number: the answer.
Sample Input
3 9
2 123
1 1 1
2 123
1 1 2
2 123
1 1 3
2 123
1 2 1
2 123
Sample Output
0
1
2
1
2
Constraints
- for every operation