#include <stdio.h>

#define MAX 100003

int p[MAX],l[MAX],r[MAX],d[MAX];

void depth(int x,int dep){
  d[x]=dep;
  if(r[x]!= -10)depth(r[x],dep);
  if(l[x]!= -10)depth(l[x],dep+1);
}

int main(){
  int i,j,n,m,v,t,ll,root;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    p[i]=-1;
    l[i]=-10;
    r[i]=-10;
  }

  for(i=0;i<n;i++){
    scanf("%d",&v);
    scanf("%d",&m);
    for(j=0;j<m;j++){
      scanf("%d",&t);
      if(j==0)l[v]=t;
      else r[ll]=t;
      ll=t;
      p[t]=v;
    }
  }

  for(i=0;i<n;i++){
    if(p[i]==-1){
      root=i;
      break;
    }
  }

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

  return 0;
}

