#include <stdio.h>

typedef struct T{
  int id;
  int k;
  int c[10];
  int parent;
  int depth;
}t;

int main(){

  int i,j,l,n,flag=1,dep=0,par;
  t tree[100],temp;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    
    scanf("%d",&tree[i].id);

    scanf("%d",&tree[i].k);
     tree[i].parent = 0;
    for(j=0;j<tree[i].k;j++){
      scanf("%d",&tree[i].c[j]);
    }
  }


  /*parent,root????±???????*/

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      for(l=0;l<tree[j].k;l++){
	if(tree[i].id==tree[j].c[l]){
	  flag = 0;
	  tree[i].parent = tree[j].id;
	}
      }
    }
    if(flag == 1){
      tree[i].parent = -1;
      flag = 0;
    }
    flag = 1;
  }
  
  l = 0;
 for(i=0;i<n;i++){
      par = tree[i].parent;
      while(par!=-1){
	if(tree[l].id==par){
	  dep++;
	  par = tree[l].parent;
	    }
	l++;
      }
    
      tree[i].depth = dep;
      l = 0;
      dep = 0;
      }

 /*?????????*/
 for(i=0;i<n;i++){
   flag = 1;
   while(flag){
     flag = 0;
     for(j=n-1;1<=j;j--){
       if(tree[j].id<tree[j-1].id){
	 temp = tree[j-1];
	 tree[j-1] = tree[j];
	 tree[j] = temp;
	 flag = 1;
       }
     }
   }
 }


  for(i=0;i<n;i++){
    printf("node %d: ",tree[i].id);
    printf("parent = %d,",tree[i].parent);

    printf(" depth = %d,",tree[i].depth);

    if(tree[i].k != 0 && tree[i].parent != -1)printf(" internal node,");
    else if(tree[i].parent == -1) printf(" root,");
    else printf(" leaf,");

    if(tree[i].k==0){
	printf(" []\n");
	continue;
      }
    printf(" [");
    for(j=0;j<tree[i].k-1;j++){
      printf("%d, ",tree[i].c[j]);
    }
    printf("%d]",tree[i].c[j]);
    printf("\n");
}

  return 0;
}