#include <stdio.h>
#include <string.h>
#define MAX 100005
#define END -1

typedef struct {
  int parent;
  int next;
  int rig;
  
}Node;
  
Node tree[MAX];
int s_dep(int,int);
int main(void){

  int i,t,n,id,deg,cha,fr;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    tree[i].parent=END;
    tree[i].next=END;
    tree[i].rig=-1;

  }

  //input the tree
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&deg);
    for(t=0;t<deg;t++){
      scanf("%d",&cha);
      if(t==0){
        tree[cha].parent=id;
        tree[id].next = cha;
        fr = cha;
      }
      else {
        tree[fr].rig = cha;
        tree[cha].parent = id;
        fr = cha;
      }
    }    
  }
  //output the tree
  for(i=0;i<n;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",tree[i].parent);
    printf("depth = %d, ",s_dep(i,0));
    if(tree[i].parent==END) printf("root, [");
    else if(tree[i].next != END) printf("internal node, [");
    else {
      printf("leaf, []\n");
      continue;
    }
    printf("%d",tree[i].next);
    cha =  tree[i].next;
    while(1){
      if(tree[cha].rig !=END){
        printf(", %d",tree[cha].rig);
        cha = tree[cha].rig;
      }
      else break;
      
    }
    printf("]\n");
    
    
  }
  
  return 0;
}


int s_dep(int id,int c){
  int i;
  int de = 0;

  if(tree[id].parent!=-1){
    de = s_dep(tree[id].parent,c);
    return de+1;
  }
  else return c;

}
ss