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

typedef struct TREE{
	int id;
	int depth;
	int k;
	struct TREE *parent;
	struct TREE **child;
}Tree;

Tree* get(int id, Tree* nt){
	int i;
	Tree *re = NULL;
	if( nt == NULL ){ return NULL; }
	if( nt->id == id ){ return nt; }
	for( i = 0; i < nt->k; i++ ){
		re = get(id, nt->child[i]);
		if( re != NULL ){ break; }
	}
	return re;
}

void print(Tree *p){
	int parent, nodetype, i;
	char *nodename[] = {"root", "internal node", "leaf"};
	if( p == NULL ){ return; }
	if( p->parent == NULL ){
		parent = -1;
	}else{
		parent = p->parent->id;
	}
	if( parent == -1 ){
		nodetype = 0;
	}else if( p->k > 0 ){
		nodetype = 1;
	}else{
		nodetype = 2;
	}
	printf("node %d: parent = %d, depth = %d, ", p->id, parent, p->depth);
	printf("%s, ", nodename[nodetype]);
	printf("[");
	if( p->k > 0 ){
		printf("%d", p->child[0]->id);
		for( i = 1; i < p->k; i++ ){
			printf(", %d", p->child[i]->id);
		}
	}
	printf("]\n");
	return;
}

int main(){
	int n, id, i, j;
	scanf("%d", &n);
	Tree *parent = NULL, *temp, *tempc;
	for( i = 0; i < n; i++ ){
		scanf("%d", &id);
		if( parent == NULL ){
			temp = (Tree*)malloc(sizeof(Tree));
			parent = temp;
			temp->id = id;
			temp->depth = 0;
			temp->parent = NULL;
		}else{
			temp = get(id, parent);
			if( temp == NULL ){ return -1; }
		}
		//???????????????
		scanf("%d", &temp->k);
		temp->child = (Tree**)malloc(sizeof(Tree*)*temp->k);
		for( j = 0; j < temp->k; j++ ){
			tempc = (Tree*)malloc(sizeof(Tree));
			temp->child[j] = tempc;
			scanf("%d", &tempc->id);
			tempc->depth = temp->depth + 1;
			tempc->k = -1;
			tempc->parent = temp;
			tempc->child = NULL;
		}
	}
	for( i = 0; i < n; i++ ){
		temp = get(i, parent);
		print(temp);
	}
	return 0;
}