#include<stdio.h>
#define N 100000

typedef struct{
  int p;
  int sib;
  int left;
  int right;
  int deg;
  int dep;
  int hei;
}Node;

Node T[N];

void depth(int,int);

int main(){
  int n,i,j,key,num,c=0,d;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
   T[i].p=-1;
   T[i].left=-1;
   T[i].right=-1;
   T[i].sib=-1;
   }
   for(i=0;i<n;i++){
    scanf("%d",&key);
    scanf("%d",&T[i].deg);
    for(j=0;j<T[i].deg;j++){
      scanf("%d",&num);
      T[num].p=key;    
      if(j==0) T[key].left=num;
      else T[c].right=num;
      c=num;
    }
   }
    for(i=0;i<n;i++){
    if(T[i].p==-1) {
       T[i].dep=0;
        depth(i,T[i].dep);
     }
    }
    for(i=0;i<n;i++){
      printf("node %d: parent = %d, depth = %d, ",i,T[i].p,T[i].dep);
    if(T[i].p==-1) printf("root, ");
    else if(T[i].deg==0) printf("leaf, ");
    else printf("internal node, ");
    printf("[");
     for(j=0;j<T[i].deg;j++){
       if(j==T[i].deg-1 && j==0) printf("%d",T[i].left);
       else if (j==T[i].deg-1)  printf("%d",T[d].right);
       else if(j==0) {printf("%d, ",T[i].left);
         d=T[i].left;}
       else {printf("%d, ",T[d].right);
          d=T[d].right;
	 }
     }
     printf("]\n");
    }
    return 0;
    }

void depth(int id,int count){
  int j,d;

  T[id].dep=count;
  if(T[id].left==-1)return;
  else   for(j=0;j<T[id].deg;j++){
	   if(j==0)d=T[id].left;
           else d=T[d].right;
            depth(d,T[id].dep+1);
    }
}