#include<stdio.h>
#define NIL -1
#define Max 100005
typedef struct{
  int parent;
  int left;
  int right;
}Node;

Node T[Max];
int depth[Max];
void r(int,int);
void r(int node ,int parent){
  depth[node] = parent;
  if(T[node].right != NIL){
    r(T[node].right,parent);
  }
  if(T[node].left != NIL){
    r(T[node].left,parent + 1);
  }
}
int main(){
  int Num,Index,node,left=0,root,n,i,j;
  scanf("%d",&n);
  for(i = 0;i < n;++i){
    T[i].right=NIL;
    T[i].left=T[i].right;
    T[i].parent=T[i].left;
  }
  for(i = 0;i < n;++i){
    scanf("%d %d",&Index,&Num);
    for(j = 0;j<Num;++j){
      scanf("%d",&node);
      if(j == 0){
	T[Index].left = node;
      }
      else{
	T[left].right = node;
      }
      left = node;
      T[node].parent = Index;
    }
  }
    
  for(i = 0;i < n;++i){
    if(T[i].parent == NIL){
      root = i;
    }
  }
   
  r(root,0);
            
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ", i,T[i].parent, depth[i]);
    
    if(T[i].parent == NIL){
      printf( "root, ");
    }else if(T[i].left == NIL){
      printf("leaf, ");
    }else{
      printf("internal node, ");
    }
    printf("[");
    
    for(j = 0,left = T[i].left;left != NIL;++j,left = T[left].right){
      if(j)printf(", ");
      printf("%d", left);
    }
    printf("]\n");
  }
  return 0;
}

