In the programming academy, students enjoy learning from each other, where each person can become the “seafu” of others. Over time, this has led to a unique hierarchical system similar to a tree structure.
Within the academy, every student has exactly one "direct seafu,” except for the "Master FrankLee”, who sits atop the academy's hierarchy. He is the only one without a "direct seafu”, and he is the “seafu” of every students.
There are N students in the academy, each person has a uniuqe id number from 1 ~ N. There is a unique custom in the academy, seafu's id must be smaller than disciples' id. So "FrankLee" is always id number 1.
Now give you every student's direct seafu's id (except “FrankLee”), please answer the following questions.
Note: a student can be more than 1 students' "direct seafu", but can only have 1 "direct seafu".
Disciples Query:
Given an id number X. Output the number of disciples of student X.
A person is disciple of student X if student X is this person’s seafu. So Master FrankLee has N-1 disciples.
Seafu Test:
Given 2 id numbers A, B. (A≠B)
Check if student A is B’s seafu or student B is A’s seafu or neither.
if student A is B’s seafu, output "1".
if student B is A’s seafu, output "0".
if neither output "-1"
Note: A person x is person y’s seafu if person x is y’s direct seafu or y’s direct seafu’s direct seafu or y’s direct seafu’s direct seafu’s direct seafu, and so on…