#include<stdio.h>
#include<stdlib.h>

struct Tree{
  int parent;
  int left;
  int right;
};

struct Tree T[100000];
int D[100000];
int a=0;

void rec(int u,int p){
  D[u]=p;
  if(T[u].right!=-1) rec(T[u].right,p);
  if(T[u].left!=-1) rec(T[u].left,p+1);
}

int main(){
  int n,i,j,d,v,c,l=0,r=0,max=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=-1;
    T[i].left=-1;
    T[i].right=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d",&v);
    scanf("%d",&d);
    if(d>max)max=d;
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0) T[v].left=c;
      else T[l].right=c;
      l=c;
      T[c].parent=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].parent==-1)r=i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,D[i]);
    if(T[i].parent==-1){
      printf("root, ");
    }
    else if(T[i].left==-1){
      printf("leaf, ");
    }
    else printf("internal node, ");
    
    printf("[");
    for(j=0,c=T[i].left;c!=-1;j++,c=T[c].right){
      if(j>0)printf(", ");
      printf("%d",c);
    }
    printf("]\n");
  }
  
  return 0;
  
}
  

