/*
 *	Argorithms and Data Structures
 *	Lectuire 7 
 *	BinaryTrees
 */

#include <stdio.h>
//#include <stdlib.h>

#define N 25

struct Node{
	struct Node *parent;
	int id;
	struct Node *left;
	struct Node *right;
};
typedef struct Node Node;

Node node[N];
Node NID = { NULL, -1, NULL, NULL};

int parent( Node* );
int sibling( Node* );
int degree( Node* );
int depth( Node* );
int height( Node* );
char* type( Node* );

int main(void){

	int i;

	int n_node;
	int id, l_id, r_id;
	Node *p_nd;
	scanf("%d",&n_node);
	
	/* Input */
	for(i=0; i<n_node; i++){
		scanf("%d", &id);
		scanf("%d %d", &l_id, &r_id);

		node[id].id = id;
		if( l_id == -1 ){
			node[id].left = node[id].right = &NID;
		}
		else {
			node[id].left = &node[l_id];
			node[id].right = &node[r_id];
			node[l_id].parent = node[r_id].parent = &node[id];
		}
	}


	/* Output */
	for(id=0; id<n_node; id++){
		p_nd = &node[id];
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n"
		, id, parent(p_nd), sibling(p_nd), degree(p_nd), depth(p_nd), height(p_nd), type(p_nd) );
	}

	return 0;
}

int parent( Node* p_node ){
	return p_node->parent->id;
}
int sibling( Node* p_node ){
	if(p_node->parent->id == -1)
		return -1;
		
	if( p_node->parent->left->id == p_node->id )
		return p_node->parent->right->id;
	return p_node->parent->left->id;
}
int degree(Node* p_node){
	if( p_node->left->id == -1)
		return 0;
	return 2;
}

// --- recursive function
int depth( Node* p_node ){
	if (p_node->parent->id == -1)
		return 0;
	return 1 + depth( p_node->parent ); 
}
int height( Node* p_node ){
	if (p_node->left->id == -1)
		return 0;

	if (height( p_node->left ) > height( p_node->right) )
		return height( p_node->left ) + 1;
	else 
		return height( p_node->right ) + 1;
}
// ---

char* type( Node* p_node ){
	if(p_node->parent->id == -1) return "root";
	if(p_node->left->id == -1) return "leaf";
	return "internal node";	
}