#include<stdio.h>

#define MAX 100000
typedef struct{
  int parent;
  int right;
  int left;
}Tree;

Tree tree[MAX];
int n,tt[MAX];

void ccccc(int,int);

int main(){
  int i,j,q,r,c,right,left;

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ )
    {
      tree[i].parent = -1;
      tree[i].right = -1;
      tree[i].left = -1;
    }

  for( i = 0 ; i < n ; i++ )
    {
      scanf("%d%d",&r,&q);
      for( j = 0 ; j < q ; j++ )
        {
          scanf("%d",&c);
          if( j == 0 ) tree[i].left=c;
          else tree[left].right = c;
          left = c;
          tree[c].parent = i;
        }
    }

  for( i = 0 ; i < n ; i++ ){
    if(tree[i].parent == -1) right =i;
  }

  ccccc(right,0);

  for(i = 0 ; i < n ; i++ ){
    printf("node %d: parent = %d, depth = %d, ",i,tree[i].parent,tt[i]);
    if(tree[i].parent == -1 ) printf("root, [");
    else if(tree[i].left == -1 ) printf("leaf, [");
    else printf("internal node, [");

    for(j = 0,c=tree[i].left;c!=-1;j++,c=tree[c].right){
      if(j) printf(", ");
      printf("%d",c);
    }
    printf("]\n");
  }

  return 0;
}

void ccccc(int u,int p){
  tt[u]=p;
  if(tree[u].right!=-1) ccccc(tree[u].right,p);
  if(tree[u].left!=-1) ccccc(tree[u].left,p+1);
}

