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。