Preparando MOJI
You are given a tree with n vertices and you are allowed to perform no more than 2n transformations on it. Transformation is defined by three vertices x, y, y' and consists of deleting edge (x, y) and adding edge (x, y'). Transformation x, y, y' could be performed if all the following conditions are satisfied:
You should minimize the sum of squared distances between all pairs of vertices in a tree, which you could get after no more than 2n transformations and output any sequence of transformations leading initial tree to such state.
Note that you don't need to minimize the number of operations. It is necessary to minimize only the sum of the squared distances.
The first line of input contains integer n (1 ≤ n ≤ 2·105) — number of vertices in tree.
The next n - 1 lines of input contains integers a and b (1 ≤ a, b ≤ n, a ≠ b) — the descriptions of edges. It is guaranteed that the given edges form a tree.
In the first line output integer k (0 ≤ k ≤ 2n) — the number of transformations from your example, minimizing sum of squared distances between all pairs of vertices.
In each of the next k lines output three integers x, y, y' — indices of vertices from the corresponding transformation.
Transformations with y = y' are allowed (even though they don't change tree) if transformation conditions are satisfied.
If there are several possible answers, print any of them.
3
3 2
1 3
0
7
1 2
2 3
3 4
4 5
5 6
6 7
2
4 3 2
4 5 6
This is a picture for the second sample. Added edges are dark, deleted edges are dotted.