#include <stdio.h>

typedef struct{
  int p;
  int num;
  int c[100];
  int pare;
  int depth;
}Tree;

Tree tree[100];

int main(){
  
  int i,j,k,n,flag,c,count=0;

    
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d%d",&tree[i].p,&tree[i].num);
    for(j=0;j<tree[i].num;j++){
      scanf("%d",&tree[i].c[j]);
    }
  }

  for(i=0;i<n;i++){
    flag = 0;

    for(j=0;j<n;j++){
      for(k=0;k<tree[j].num;k++)
	if(tree[i].p == tree[j].c[k]){
	  tree[i].pare = tree[j].p;
	  flag = 1;
	}
    }
    if(flag == 0){
      tree[i].pare = -1;
    }
  }

  for(i=0;i<n;i++){
    c = tree[i].pare;
    while(1){
      if(c == -1) break;
      c = tree[c].pare;
      count++;
    }
    tree[i].depth = count;
    count = 0;
  }

  printf("\n");

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",tree[i].p,tree[i].pare,tree[i].depth);
    if(tree[i].pare == -1) printf("root, [");
    else if(tree[i].num == 0) printf("leaf, [");
    else printf("internal node, [");
  
    for(j=0;j<tree[i].num;j++){
      if(j == tree[i].num-1) printf("%d",tree[i].c[j]);
      else printf("%d, ",tree[i].c[j]);
    }
    printf("]\n");
  }

  return 0;
}