Whoa! You did a great job helping Team Rocket who managed to capture all the Pokemons sent by Bash. Meowth, part of Team Rocket, having already mastered the human language, now wants to become a master in programming as well. He agrees to free the Pokemons if Bash can answer his questions.
Initially, Meowth gives Bash a weighted tree containing
n nodes and a sequence
a1,a2...,an which is a permutation of
1,2,...,n. Now, Mewoth makes
q queries of one of the following forms:
- 1 l r v: meaning Bash should report , where dist(a,b) is the length of the shortest path from node a to node b in the given tree.
- 2 x: meaning Bash should swap ax and ax+1 in the given sequence. This new sequence is used for later queries.
Help Bash to answer the questions!
Output
For each query of type
1, output a single integer in a separate line, denoting the answer to the query.
Note
In the sample, the actual queries are the following:
- 1 1 5 4
- 1 1 3 3
- 2 3
- 2 2
- 1 1 3 3