#include <stdio.h>
#define N 200001
#define NT -1

struct Node{
    int p,left,right;
};

struct Node T[N];
int getDepth(int p){
    if(T[p].p == NT) return 0;
    return getDepth(T[p].p)+1;
}
int main()
{
    int n,i,key,j,c;
    int id,temp;
    int depth[N];

    scanf("%d",&n);

    for( i=0;i<n;i++){

      T[i].p=T[i].left=T[i].right=NT;
    }
    
    for(i=0;i<n;i++){

      scanf("%d%d",&id,&key);

	for(j=0;j<key;j++){

	  scanf("%d",&c);

	    if(j==0){
                T[id].left=c;
                T[c].p=id;
                temp=c;
            }

	    else{
                T[temp].right=c;
                T[c].p=id;
                temp=c;
            }
        }
    }
    for(i=0;i<n;i++)
      depth[i]=getDepth(i);
    
    for(i=0;i<n;i++){
      printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth[i]);

      ifif(T[i].p==NT)
	printf("root, [");
      else  if(T[i].left==NT)
	printf("leaf, [");
       
      else
	printf("internal node, [");

      if(T[i].left != NT){
	printf("%d",T[i].left);
                temp = T[i].left;
		
                while(1){
                    if(T[temp].right==NT) break;
                    printf(", %d",T[temp].right);
                    temp = T[temp].right;
                }
		
            }
            printf("]\n");
        }
  return 0;
}

