#include<stdio.h>
typedef struct{
  int parent;
  int left;
  int right;
} Tree;
Tree a[100000];
int Depth(int);
int Degree(int);

int main(){
int n,Num;
int id,k=0;
int i,j,h;
scanf("%d",&n);
for(i=0;i<n;i++){
  a[n].parent=-1;
  a[n].left=-1;
  a[n].right=-1;
}

scanf("%d",&n);
  for(i=0; i<n; i++)
    {
      a[i].parent = -1;
      a[i].left = -1;
      a[i].right = -1;
    }

  for(i=0; i<n; i++)
   {
      scanf("%d%d",&id,&k);
    for(j = 0; j < k; j++){
      scanf("%d",&Num);
      a[Num].parent = id;
      if(j == 0){
        a[id].left = Num;
      }
      else{
     a[h].right = Num;
      }
      h = Num;

    }
  }

for(i=0;i<n;i++){
  printf("node %d: parent=%d,",i,a[i].parent);
  Depth(i);
  if(a[i].parent == -1){
    printf("root, [");
  }
  else if(a[i].left == -1){
    printf("leaf, [");
  }
else{
    printf("internal node, [");
  }
  Degree(a[i].left);
  printf("]\n");
}
return 0;
}
int Depth(int i){
  int d=0;
  while (a[i].parent != -1){
  i=a[i].parent;
  d++;
}
  return d;
}
int Degree( int t){
  if(t==-1){
return 0;
  }
  else{
    if(a[t].right == -1){
      printf("%d",t);

    }

  else {
    printf("%d ",t);
    Degree(a[t].right);

  }
  return 0;
}
}

