F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Fxx and factory

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/131072 K (Java/Others)
Total Submission(s): 106    Accepted Submission(s): 0


Problem Description
Young theoretical computer scientist Fxx goes to a factory.

In the factory,there are $n$ receiving barrel in a row from left to right.The plan has m operations,and each operation has to be one of the following three ways

$(1,x,y)\:$£ºput $y$ products into $x\:$th barrel(counted from left to right).

$(2,x)\:$£ºTake out all the products in the $x$th barrel(counted from left to right).

$(3,x,y)\:$ Swap the $x$th barrel and $y$th barrel(counted from left to right)

Then the factory will continue to repeat the $m$ operations in turn,and give $Q$ queries,each query will give an integer $k$, asking after $mk$ operations(repeat the $m$ operations $k$ times),the maximum number of products in the $n$ barrel¡£
 

Input
In the first line, there is an integer $T(T\leq 5)$ indicating the number of test cases.

For each case, the first line contains three integers $n,m,Q(n\leq1000,m\leq10^5,Q\leq3\times10^5)$

In the next $m$ lines,each line contains an operation.

In the next $Q$ lines,each line contains an integer $k(k\leq10^9)$ indicating an query.

We guarantee that each answer is no more than $10^{18}$.

We guarantee that the number of operation $2$ is no more than 100, under this condition, all other operations are randomly.

<b>This problem does not support hack.</b>
 

Output
Print a response for each query in a separate line.
 

Sample Input
1 3 6 4 1 2 7 1 1 8 3 1 3 1 1 4 2 2 1 2 2 1 3 5 12
 

Sample Output
8 20 32 72
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 08:56:38, Gzip enabled