#include <stdio.h>
#define N 100

int main() {

  int n ,i ,j ,c;

  int in[N][2] ,out[N][N] ,d[N] ,p[N];

  scanf("%d" ,&n);

  for(i=0;i<n;i++){
    scanf("%d%d" ,&in[i][0] ,&in[i][1]);
    for(j=0;j<in[i][1];j++){
      scanf("%d",&out[i][j]);
    }
  }

  for(i=0;i<n;i++){
    if(in[i][0]==0) {
      p[i]=-1;
      d[i]=0;
    }
    else for(j=0;j<n;j++){
        for(c=0;c<in[j][1];c++){
          if(in[i][0]==out[j][c]) p[i]=in[j][0];
        }
      }
    if(p[i]!=p[i-1] && p[i]!=0) d[i]=d[i-1]+1;
    else if(p[i]!=p[i-1] && p[i]==0) d[i]=1;
    else if(p[i]==p[i-1]) d[i]=d[i-1];
  }






  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d,",i ,p[i] ,d[i]);
    if(d[i]==0) printf("root, [");
    else if(d[i]==1) printf("internal node, [");
    else if(d[i]>1) printf("leaf, [");
    for(j=0;j<in[i][1];j++){
      if(j==in[i][1]-1) printf("%d",out[i][j]);
      else printf("%d, ",out[i][j]);
    }
    printf("]\n");
  }

  return 0;
}

