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

#define MAX 100000
#define ROOT 0
#define INODE 1
#define LEAF 2

struct CHILDREN {
	int id;
	struct CHILDREN *next;
};
typedef struct CHILDREN CHILDREN;

struct NODE {
	int parent;
	short depth;
	short type;
	CHILDREN *children;
};
typedef struct NODE NODE;

int main( void ) 
{   
    int n;
    int id,k,c,prec;
    int i,j,depth;
    char types[3][32] = { "root", "internal node", "leaf" };
	NODE nodes[ MAX+1 ];
	CHILDREN *child=NULL,*pre=NULL;
	       
    scanf( "%d", &n );
    for( i=0; i<n; i++ ) {
        scanf( "%d%d", &id, &k );
        if( k ) {
        	if( 0 == nodes[id].depth ) {
        		nodes[id].parent = -1; 
        	} else {
          		nodes[id].type=INODE;        	
        	}
       		prec=id;
       		child = (CHILDREN *)malloc( sizeof( CHILDREN ) );
       		nodes[id].children=child;
       		pre=child;
        	for( j=0; j<k; j++ ) {
	           	scanf( "%d", &c );
	           	if( !nodes[j].type ) {
          			nodes[j].type=INODE;        	
        		}
	           	nodes[c].parent=id;
	           	nodes[c].depth=nodes[id].depth+1;
	           	child->id=c;
	           	pre->next=child;
	           	pre=child;
	           	if( j < k-1 ) {
	      			child = (CHILDREN *)malloc( sizeof( CHILDREN ) );
	      		}
        	}
        	pre->next=NULL;     	
       	} else {
       		nodes[id].type=LEAF;
	   		nodes[id].children=NULL;
       	}
    }
    if( 1 == n ) {
    	nodes[id].parent = -1; 
    	nodes[id].type=ROOT;
   	}
    
    for( i=0; i<n; i++ ) {
    	depth=(-1 == nodes[i].parent)? 0: nodes[ nodes[i].parent ].depth+1;
		printf( "node %d: parent = %d, depth = %d, %s, ", i, nodes[i].parent,  depth,  types[ nodes[i].type ] );
		if( NULL != nodes[i].children ) {
			child=nodes[i].children;
			printf( "[%d", child->id );
			child=child->next;
			while( NULL != child ) {
				printf( ", %d", child->id );
				child=child->next;
			}
			printf( "]\n" );
		} else {
			printf( "[]\n" );
		}
	}

    return 0;
}