A rooted binary tree is a tree with a root node in which every node has at most two children.

Your task is to write a program which reads a rooted binary tree T and prints the following information for each node u of T:

* node ID of u
* parent of u
* sibling of u
* the number of children of u
* depth of u
* height of u
* node type (root, internal node or leaf)



If two nodes have the same parent, they are siblings. Here, if u and v have the same parent, we say u is a sibling of v (vice versa).

The height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf.

Here, the given binary tree consists of n nodes and evey node has a unique ID from 0 to n-1.

Constraints

* 1 ≤ n ≤ 25

Input

The first line of the input includes an integer n, the number of nodes of the tree.

In the next n lines, the information of each node is given in the following format:

id left right

id is the node ID, left is ID of the left child and right is ID of the right child. If the node does not have the left (right) child, the left(right) is indicated by -1.

Output

Print the information of each node in the following format:

node id: parent = p, sibling = s, degree = deg, depth = dep, height = h, type


p is ID of its parent. If the node does not have a parent, print -1.

s is ID of its sibling. If the node does not have a sibling, print -1.

deg, dep and h are the number of children, depth and height of the node respectively.

type is a type of nodes represented by a string (root, internal node or leaf. If the root can be considered as a leaf or an internal node, print root.

Please follow the format presented in a sample output below.

Example

Input

9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1


Output

node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root
node 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node
node 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf
node 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf
node 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node
node 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node
node 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf
node 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf
node 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf
import java.util.*;

abstract class Elt {

	private int id;
	private Elt parent,left,right;
	
	//Constructor
	public Elt(int id){this.id = id;}
	
	//getter,setter
	public int getId() {return id;}

	public Elt getParent() {return parent;}
	public void setParent(Elt parent) {this.parent = parent;}
	
	public Elt getLeft() {return left;}
	public void setLeft(Elt left) {this.left = left;}
	
	public Elt getRigth() {return right;}
	public void setRigth(Elt rigth) {this.right = rigth;}
}

class Element extends Elt implements Comparable<Element>{

	public int parent,sibling,left,right,degree,height,depth;
	public String type;
	
	public Element(int id){super(id);}

	public String toString(){
		return "node " + getId() + ": parent = " + parent + ", sibling = " + sibling + ", degree = " + degree + ", depth = " + depth +", height = " + height + ", " + type;
	}

	public int compareTo (Element e){
		return this.getId() - e.getId();
	}
}

public class Main {

	public static final int    ROOT      = -1;
	public static final int    EMPTY     = -1;
	public static final String ROOT_TYPE = "root";
	public static final String NODE_TYPE = "internal node";
	public static final String LEAF_TYPE = "leaf";
	
	private static ArrayList<Element> tree = new ArrayList<Element>();

    public static void main(String[] args) {

    	input();

    	//edit
    	set_2();
    	set_3();
    	set_4();
    	set_5();
    	set_7();
    	set_6();
    	
    	//sort by id.
    	Collections.sort(tree);

    	output();
    }

	private static void input() {
    	Scanner sc = new Scanner(System.in).useDelimiter(System.getProperty("line.separator"));
    	int N = sc.nextInt();

    	String[] s = null;
    	Element  e = null;
        for(int i = 0; i < N; i++){
        	s = sc.next().split("\\s");
        	e = new Element(Integer.parseInt(s[0]));
        	e.left  = Integer.parseInt(s[1]);
        	e.right = Integer.parseInt(s[2]);
        	e.height = EMPTY; //?????????
        	tree.add(e);
        }
	}

	private static void set_2(){
		int tree_size = tree.size();
		for(int i = 0; i < tree_size; i++){
			Element child = tree.get(i);
			Element parent = get_parent(child);
			if(parent == null){
				child.parent = ROOT;
				continue;
			}
			child.parent =  parent.getId();
		}
	}

	private static Element get_parent(Element child){
		Element ret   = null;
		for(Element parent:tree){
			if(child.getId() == parent.getId()){continue;}
			if(child.getId() == parent.left || child.getId() == parent.right){
				ret = parent;
			}
		}
		return ret;
	}

	private static void set_3(){
		Element sibling = null;
		int tree_size = tree.size();
		for(int i = 0; i<tree_size; i++){
			sibling = get_sibling(i);
			if(sibling == null){
				tree.get(i).sibling = EMPTY;
				continue;
			}
			tree.get(i).sibling = sibling.getId();
		}
	}

	private static Element get_sibling(int index){
		Element  child = tree.get(index),
		        parent = get_parent(child),
		        ret    = null;

		if(parent == null){return ret;}

		for(Element e:tree){
			if(parent.left  == child.getId() && parent.right == e.getId()){ret = e;}
			if(parent.right == child.getId() && parent.left  == e.getId()){ret = e;}
		}
		return ret;
	}

	private static void set_4(){
		int size = tree.size();
		for(int i=0;i<size;i++){
			set_degree(i);
		}
	}

	private static void set_degree(int index){
		Element e = tree.get(index);
		int cnt = 0;
		if(e.right != EMPTY){cnt++;}
		if(e.left != EMPTY){cnt++;}
		e.degree = cnt;
	}

	private static void set_5(){
		for(int i=0;i<tree.size();i++){
			tree.get(i).depth=calc_depth(i);
		}
	}
	private static int calc_depth(int i){
		int depth = 0;
		Element e = tree.get(i);
		for(int id=e.getId();;depth++){
			id=searchParent(id);
			if(id==-2){System.err.println("parent search error");}
			if(id==ROOT){break;}
		}
		return depth;
	}

	private static int searchParent(int id){
		for(Element e:tree){
			if(id==e.getId()){return e.parent;}
		}
		return -2;
	}

	private static void set_6(){
		for(Element e:tree){
			if(e.right == EMPTY && e.left == EMPTY){
				for(int height = 0;e.height == EMPTY || e.height < height;height++){
					e.height = height;
					e = get_parent(e);
					if(e == null){break;}
				}
			}
		}
	}

	private static void set_7(){
		for(Element e:tree){
			if(e.parent==ROOT){e.type=ROOT_TYPE;}
			if(e.parent!=ROOT && (e.right!=EMPTY || e.left!=EMPTY)){e.type=NODE_TYPE;}
			if(e.parent!=ROOT && (e.right==EMPTY && e.left==EMPTY)){e.type=LEAF_TYPE;}
		}
	}

	private static void output(){
		for(Element e:tree){
			System.out.println(e);
		}
	}
}