Ameba
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Problem Statement
You observed amoebae and kept some records.
Initially, there was one amoeba, numbered .
You made records. According to the -th record, the amoeba numbered disappeared by dividing itself into two new amoebae, which were then numbered and .
Here, amoeba is said to be the parent of amoebae and .
For each , how many generations away is amoeba from amoeba ?
Constraints
- The records are consistent. That is:
- .
- are distinct integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the generation distance between amoeba and amoeba .
Sample Input 1
2
1 2
Sample Output 1
0
1
1
2
2
From amoeba , amoebae and were born. From amoeba , amoebae and were born.
- Amoeba is zero generations away from amoeba .
- Amoeba is one generation away from amoeba .
- Amoeba is one generation away from amoeba .
- Amoeba is one generation away from amoeba , and two generations away from amoeba .
- Amoeba is one generation away from amoeba , and two generations away from amoeba .
Sample Input 2
4
1 3 5 2
Sample Output 2
0
1
1
2
2
3
3
2
2