using System;

public class BinaryTree {
    public static int NIL = -1; // ??????????????????	

    public const int MIN_N = 1;
    public const int MAX_N = 25;

    public const int NODE_MAX = MAX_N + 10;

    public const string ROOT = "root";
    public const string LEAF = "leaf";
    public const string INTERNAL_NODE = "internal node";

    public static Node[] T = new Node[NODE_MAX];

    // ?????????????§???????
    public struct Node {		
	public int id, parent, left, right;

	public Node(int _id, int _left, int _right) {
	    id     = _id;
	    left   = _left;
	    right  = _right;
	    parent = NIL;
	}

	// ???????????????(sibling)???ID?????????
	public int sibling() {
	    int parentID = this.parent;
	    if (parentID == NIL) {
		return NIL; // ????????????(root)
	    }
	    Node parentNode = BinaryTree.T[parentID];
	    // ???????????????????????´???
	    if (this.id == parentNode.left) {
		return (parentNode.right != NIL) ? parentNode.right : NIL;
	    }
	    // ???????????????????????´???
	    if (this.id == parentNode.right) {
		return (parentNode.left != NIL) ? parentNode.left : NIL;
	    }
	    // ????????????
	    return NIL;
	}

	// ????????°?????????
	public int degree() {
	    int degree = 0;
	    if (this.left != NIL) {
		degree++;
	    }
	    if (this.right != NIL){
		degree++;
	    }
	    return degree;
	}

	// ??±????????????
	public int depth(Node node) {
	    int d = 0;
	    if (node.parent != NIL) {
		d = depth(BinaryTree.T[node.parent]) + 1;
	    }
	    return d;
	}    

	// ?????????id??????????????£???????????\?????????????????????
	public int height(Node node) {
	    int h1 = 0;
	    int h2 = 0;
	    if (node.left != NIL) {
		h1 = height(BinaryTree.T[node.left]) + 1;
	    }
	    if (node.right != NIL) {
		h2 = height(BinaryTree.T[node.right]) + 1;
	    }
	    return Math.Max(h1, h2);
	}

	// ????????????????????????????????????????????????
	public string type() {
	    // root: ???????????????
	    // leaf: ??????????????????
	    // internal node: ??????????????????
	    string type = "unknown";

	    // ????????????????????´???
	    if (this.parent == NIL) {
		return ROOT;
	    }
	    // ????????????????????´???
	    if (this.degree() == 0) {
		return LEAF;
	    }
	    // ????????????????????´???
	    if (this.parent != NIL && this.degree() != 0) {
		return INTERNAL_NODE;
	    }
	    return type;
	}
    }

    public static void Main() {
	// ??????????????°
	int N = 0;

	// ??????????????°????????????
	N = int.Parse(Console.ReadLine());
	// ??????????????§??????
	N = Math.Max(N, MIN_N);
	N = Math.Min(N, MAX_N);

	// ?????????????????±???????????????
	for (int i = 0; i < N; i++) {
	    string[] inputNode = Console.ReadLine().Split(' ');
	    int id    = int.Parse(inputNode[0]);
	    int left  = int.Parse(inputNode[1]);	    
	    int right = int.Parse(inputNode[2]);
	    BinaryTree.T[id] = new Node(id, left, right); // Node???????????????
	    BinaryTree.T[id].parent = NIL;
	}

	// ????????????????????±?????´?????????
	for (int i = 0; i < N; i++) {
	    int left = BinaryTree.T[i].left;
	    if (left != NIL) {
		BinaryTree.T[left].parent = BinaryTree.T[i].id;
	    }
	    int right = BinaryTree.T[i].right;
	    if (right != NIL) {
		BinaryTree.T[right].parent = BinaryTree.T[i].id;
	    }
	    /*
	    Node node = BinaryTree.T[i]; // Node???????????????
	    int left = node.left; // ????????????ID?????????
	    if (left != NIL) {
		Node leftChild = BinaryTree.T[left]; // ????????????????????????????????????
		leftChild.parent = node.id; // ????????±?????´??°??????
	    }		
	    int right = node.right; // ????????????ID?????????
	    if (right != NIL) {
		Node rightChild = BinaryTree.T[right]; // ????????????????????????????????????
		rightChild.parent = node.id; // ????????±?????´??°??????
	    }
	    */		
	}

	// ????????????
	for (int i = 0; i < N; i++) {
	    Node node = BinaryTree.T[i];
	    Console.WriteLine("node " + node.id + ": parent = " + node.parent + ", sibling = " + node.sibling() + ", degree = " + node.degree() + ", depth = " + node.depth(node) + ", height = " + node.height(node) + ", " + node.type());	    
	}
    }
}

Measured memory_bytes: 9112