You are a programmer and you have a New Year Tree (not the traditional fur tree, though) − a tree of four vertices: one vertex of degree three (has number 1), connected with three leaves (their numbers are from 2 to 4).
On the New Year, programmers usually have fun. You decided to have fun as well by adding vertices to the tree. One adding operation looks as follows:
-
First we choose some leaf of the tree with number v.
-
Let's mark the number of vertices on the tree at this moment by variable n, then two vertexes are added to the tree, their numbers are n+1 and n+2, also you get new edges, one between vertices v and n+1 and one between vertices v and n+2.
Your task is not just to model the process of adding vertices to the tree, but after each adding operation print the diameter of the current tree. Come on, let's solve the New Year problem!