#include<stdio.h>

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

struct NODE {
	int parent;
	int depth;
	int type;
	int children;
	int sibling;
};
typedef struct NODE NODE;

int main( void ) 
{   
    int n;
    int id,k,c,prec,tc,td;
    int i,j;
    char types[3][32] = { "root", "internal node", "leaf" };
	NODE nodes[ MAX+1 ];
	       
    scanf( "%d", &n );
    for( i=0; i<n; i++ ) {
        scanf( "%d%d", &id, &k );
        if( k ) {
        	nodes[id].type=INODE;
        	td=nodes[id].depth+1;
           	scanf( "%d", &c );
        	nodes[id].children=c;
        	nodes[c].parent=id;
        	nodes[c].depth=td;
    		if(  INODE == nodes[c].type  ) {
				tc=nodes[c].children;
				while( -1 != tc ) {
					nodes[tc].depth++;
					tc=nodes[tc].sibling;
				}
			}        	
        	prec=c;
	        for( j=1; j<k; j++ ) {
	        	scanf( "%d", &c );
	        	nodes[c].parent=id;
	        	nodes[c].depth=td;
        		nodes[prec].sibling=c;
	        	prec=c;
        		if(  INODE == nodes[c].type  ) {
					tc=nodes[c].children;
					while( -1 != tc ) {
						nodes[tc].depth++;
						tc=nodes[tc].sibling;
					}
				}
	       	}
	       	
	       	nodes[prec].sibling=c;
	       	nodes[c].sibling=-1;
       	} else {
       		if( 0 == nodes[id].parent ) { nodes[id].parent = -1; }
       		nodes[id].type=LEAF;
       		nodes[id].children=-1;
       	}
    }

    for( i=0; i<n; i++ ) {
		printf( "node %d: parent = %d, depth = %d, %s, ", i, nodes[i].parent, nodes[i].depth,  types[ nodes[i].type ] );
		if( -1 != nodes[i].children ) {
			c=nodes[i].children;
			printf( "[%d", c );
			c=nodes[c].sibling;
			while( -1 != c ) {
				printf( ", " );
				printf( "%d", c );
				c=nodes[c].sibling;
			}
			printf( "]\n" );
		} else {
			printf( "[]\n" );
		}
	}    

    return 0;
}