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

#define MAX 100001

typedef struct node{
  int p;
  int l;
  int r;
} Tree;

int main(){
  int n,i,j,id,k,c,r=0,p,d;
  Tree T[MAX];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].p=-1;
    T[i].l=-1;
    T[i].r=-1;
  }

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

    for(j=0;j<k;j++){
      scanf("%d",&c);
      T[c].p=id;

      if(j==0){
	T[id].l=c;
      }else{
	T[r].r=c;
      }

      r=c;
    }
  }

  for(i=0;i<n;i++){
    d=0;
    p=T[i].p;

    while(p!=-1){
      p=T[p].p;
      d++;
    }

    if(d==0){
      printf("node %d: parent = -1, depth = 0, root, [",i);
    }else if(T[i].l==-1){
      printf("node %d: parent = %d, depth = %d, leaf, [",i,T[i].p,d);
    }else{
      printf("node %d: parent = %d, depth = %d, internal node, [",i,T[i].p,d);
    }

    p=T[i].l;

    if(p!=-1){
      printf("%d",p);
    }

    while(p!=-1){
      p=T[p].r;

      if(p!=-1){
	printf(", %d",p);
      }
    }

    printf("]\n");
  }

  return 0;
}    