/*
 *	Argorithms and Data Structures
 *	Lectuire 7 
 *	Rooted Trees
 */

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

#define N 100000

typedef struct{
	int id_parent;
	int depth;
	int degree;
	char type[15];
	int *id_child;
} Node;

Node *node;

int depth(int);

int main(void){

	int i,j;

	int n_node, id;
	scanf("%d",&n_node);
	node = malloc(sizeof(Node) * n_node);

	/* Initialization */
	for(i=0;i<n_node;i++){
		node[i].id_parent = -1;
		strcpy(node[i].type,"root");
	}
	
	/* Input */
	for(i=0; i<n_node; i++){
		scanf("%d", &id);
		scanf("%d", &node[id].degree);
		
		/*
			(node[a])'s ID is a
			node[a] has (node[a].degree) children
		*/
		node[id].id_child = malloc( sizeof(int) * node[id].degree );
		for(j=0; j<node[id].degree; j++) {
			scanf("%d", &node[id].id_child[j]);		// You are my child.
			node[ node[id].id_child[j] ].id_parent = id;		// I am your father.
		}
	}

	for(id=0; id<n_node; id++){
		/* node[a]'s type is */
		if( node[id].id_parent != -1 ){
			if( node[id].degree > 0 )
				strcpy( node[id].type, "internal node");
			else
				strcpy( node[id].type, "leaf");
		}

		/* node[a]'s depth is */
		node[id].depth = depth( id );
	}

	/* Output */
	for(id=0; id<n_node; id++){
		printf("node %d: parent = %d, depth = %d, %s, [",
				id, node[id].id_parent, node[id].depth, node[id].type );

		for(i=0; i<node[id].degree ; i++){
			printf("%d", node[id].id_child[i]);
			if( i == node[id].degree -1 )
				break;
			printf(", ");
		}
		printf("]");
		free(node[id].id_child);


		if(id == n_node-1) break;

		printf("\n");
	}
	free(node);


	return 0;
}

int depth( int id ){
	if (node[id].id_parent == -1)
		return 0;
	return 1 + depth( node[id].id_parent ); 
}

//free id_child