Gromah and LZR are transfered to a forest, maybe it is the inner world of the great tomb. Initially, there are

rooted trees numbered from

to

with size

in the forest. For each tree, the only node is the root and labeled with

.
After a while, here comes a farmer, and the farmer gives them

planting tasks, each can be described by a tuple
_%7B%7D)
, which means to add a labeled node

for all trees numbered from

to

, and their parent nodes are the nodes labeled with

for each tree.
After finishing the planting tasks one by one, the farmer will give them

querying tasks, each can be described by a tuple
_%7B%7D)
, which means to query the sum of sizes of subtrees whose roots are the nodes labeled with

among the trees numbered from

to

. Specially, if there isn't a node labeled with

in a tree, the size of subtree

is regarded as

.
If they complete all tasks perfectly, the farmer will help them pass the final level.
Please help them handle these tasks.
The first line contains two positive integers

, denoting the number of trees in the inner world and the number of planting tasks.
Following

lines each contains four positive integers

, denoting a planting task
_%7B%7D)
.
The next line contains one positive integer

, denoting the number of querying tasks.
Following

lines each contains four positive integers

, denoting a querying task
_%7B%7D)
.
For each planting task, It is guaranteed that the label
is unique among all
s, and the trees numbered from
to
all have a node labeled with
right before handling this task.