The tree of $n \leq 50000$ has some weights $\leq 1e13$, $q \leq 400000$ operations, there are two operations: jump from $s$ to $t$ every $k$ step, less than $ The k$ step jumps directly to $t$, taking the square root of the passed point each time; in the same jumping method, sum the passed points.
First of all, the root of a number changes to 0 a few times, so it can be modified vigorously. The root number is vigorously engaged. If the block size is set to $S$, the modification of $k>S$ and the query operation can be violent; if the modification of $k<S$, a $S$ tree can be built, and the $j of the tree $i$ The father of $ is the $i$ ancestor of the original tree $j$, and then each tree chain is split + union search + BIT. . . The inquiry of $k<S$ can be found directly on BIT.
It's so hard to write QAQ