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

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

tree *TREE;

int N;

#define fr -1

void JUDGE(int);


int main(){
  int id,l,child,i,j,degree;

  scanf("%d",&N);
  TREE = (tree *)malloc(sizeof(tree)*N);
  
  for(i=0;i<N;i++){
    TREE[i].parent = fr;
    TREE[i].left = fr;
    TREE[i].right = fr;
  }
  
  for(i=0;i<N;i++){
    scanf("%d%d",&id,&degree);
  
  for(j=0;j<degree;j++){
    l = child;
    scanf("%d",&child);
    TREE[child].parent = id;

    if(j==0){
      TREE[id].left = child;
    }
    else if(j>0){
      TREE[l].right = child;
    }
  }
  }

  for(i=0;i<N;i++){
    JUDGE(i);
  }
  return 0;
}

void JUDGE(int n){
  int i = TREE[n].parent;
  int depth = 0;
  while(i!=fr){
    i = TREE[i].parent;
    depth++;
  }
  
  printf("node %d: parent = %d, depth = %d,",n,TREE[n].parent,depth);
  if(depth == 0){
    printf(" root, [");
  }
  else if(TREE[n].left == fr){
    printf(" leaf, [");
  }
  else printf(" internal node, [");

  i=TREE[n].left;
  while(i!=fr){
    printf("%d",i);

    i = TREE[i].right;

    if(i!=fr){
      printf(", ");
    }
  }
  printf("]\n");
}