#include<stdio.h>
#define NIL -1

typedef struct{
  int parent,left,right;
}tree;

void data_print(tree *inf,int i);
int depth(tree *inf,int x);

int main(){
  tree inf[100001];
  int n,pick,id,num,a,r;
  int i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    inf[i].parent=NIL;
    inf[i].left=NIL;
    inf[i].right=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&id,&pick);

    for(j=0;j<pick;j++){
      scanf("%d",&num);
      if(j==0) inf[id].left=num;
      else inf[a].right=num;
      a=num;
      inf[num].parent=id;
    }
  }

  for(i=0;i<n;i++)data_print(inf,i);

  return 0;
}

void data_print(tree *inf,int i){
  int temp;

  printf("node %d: ",i);

  printf("parent = %d, ",inf[i].parent);

  printf("depth = %d, ",depth(inf,i));

  if(inf[i].parent==NIL)printf("root, ");
  if(inf[i].parent!=NIL && inf[i].left==NIL)printf("leaf, ");
  if(inf[i].parent!=NIL && inf[i].left!=NIL)printf("internal node, ");

  printf("[");
  if(inf[i].left!=NIL){
    printf("%d",inf[i].left);
    temp=inf[i].left;
    while(inf[temp].right!=NIL){
      printf(", %d",inf[temp].right);
      temp=inf[temp].right;
    }
  }
  printf("]\n");
}

int depth(tree *inf,int num){
  int cnt=0,temp;

  while(inf[num].parent!=NIL){
    cnt++;
    temp=inf[num].parent;
    num=temp;
  }
  return cnt;
}

