#include<stdio.h>

typedef struct{
  int oya,sa,yuu;
}ki;


ki tree[100000];
int Depth[100000];

void depth(int r,int t){
  Depth[r]=t;
  if(tree[r].yuu!=-1)depth(tree[r].yuu,t);
  if(tree[r].sa!=-1)depth(tree[r].sa,t+1);
}


int main(){
  int i,j;
  int n;
  int p,q,r,s;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    tree[i].oya=tree[i].sa=tree[i].yuu=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d",&p);
    scanf("%d",&q);
    for(j=0;j<q;j++){
      scanf("%d",&r);
      if(j==0)tree[p].sa=r;
      else tree[s].yuu=r;
      s=r;
      tree[r].oya=p;
    }
  }
  int x;
  
  for(i=0;i<n;i++){
    if(tree[i].oya==-1)x=i;
  }

  depth(x,0);

  int c;
  
  for(i=0;i<n;i++){
    printf("node %d:",i);
    printf(" parent = %d,",tree[i].oya);
    printf(" depth = %d,",Depth[i]);
    if(tree[i].oya==-1)printf(" root,");
    else if(tree[i].sa==-1)printf(" leaf,");
    else printf(" internal node,");
    printf(" [");
    for(j=0,c=tree[i].sa;c!=-1;j++,c=tree[c].yuu){
      if(j!=0)printf(", ");
      printf("%d",c);
    }
    printf("]\n");
  }
      
  
  return 0;
}

