Nahida is running a simulation of Irminsul, the world tree, which stores all information about the world. In this simulation, Irminsul consists of nodes, where node
is directly below node
and node
is at the very top of the tree, and
connections connecting the nodes. The connections are formed in a way such that below each node, there are exactly
or
nodes and it is also guaranteed that you can reach any node from any other node via the connections. Node
has a maximum capacity of
units of information.
You have been tasked with helping Nahida perform operations on Irminsul, in order. The operations are of the following types
:
- Add
units of information to node
. If a node's maximum information capacity is ever exceeded, the extra information will be distributed evenly to the nodes below it. If no other nodes are below the current one, the extra information is deleted.
- Query the amount of information in node
.
Constraints
There are exactly or
nodes directly below each node.
Subtask 1 [3/15]
Subtask 2 [6/15]
Subtask 3 [6/15]
No additional constraints.
Input Specification
The first line of input contains space separated integers,
and
, the number of nodes and the number of operations respectively.
The second line of input contains space separated integers,
for
, the node directly above node
.
The third line of input contains space separated integers,
, the maximum information capacity of node
.
The next lines of input contains
,
,
for type
operations and
,
for type
operations.
Output Specification
For each type operation, output one decimal on its own line, the answer to that query. Your answer will be considered correct if it has an absolute or relative error of less than
.
Sample Input 1
5 5
1 1 2 2
1 2 3 4 5
1 1 6
2 3
2 4
1 2 1
2 5
Sample Output 1
2.5
0.25
0.75
Explanation for Sample Output 1
After the first type operation, node
is full with
unit of information. The extra
units of information are distributed evenly between node
and node
. Node
then becomes full with
units of information and the extra
units of information is distributed evenly between node
and node
.
After the second type operation, the
unit of information added to node
gets distributed evenly between node
and node
, both of which now have
units of information.
Sample Input 2
5 6
3 1 1 3
1 1 1 1 1
1 1 999
2 1
2 2
2 3
2 4
2 5
Sample Output 2
1
1
1
1
1
Comments