#include<stdio.h>
#define MAX 100005
#define NONE -1
typedef struct{
  int parent,left,right;
}Node;
Node tree[MAX];
int n,depth[MAX];
void print_out(int a){
  int i,b;
  printf("node %d: ",a);
  printf("parent = %d, ",tree[a].parent);
  printf("depth = %d, ",depth[a]);
  if(tree[a].parent == NONE) printf("root, ");
  else if(tree[a].left == NONE) printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i=0,b=tree[a].left;b!=NONE;i++,b=tree[b].right){
    if(i) printf(", ");
    printf("%d",b);
  }
  printf("]\n");
}
int dep(int a,int b){
  depth[a]=b;
  if(tree[a].right != NONE) dep(tree[a].right,b);
  if(tree[a].left != NONE) dep(tree[a].left,b+1);
}
int main(){
  int i,j,a,b,c,d,e=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    tree[i].parent = NONE;
    tree[i].left = NONE;
    tree[i].right = NONE;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&b,&a);
    for(j=0;j<a;j++){
      scanf("%d",&c);
      if(j == 0) tree[b].left = c;
      else tree[e].right=c;
      e = c;
      tree[c].parent = b;
    }
  }
  for(i=0;i<n;i++){
    if(tree[i].parent == NONE) d = i;
  }
  dep(d,0);
  for(i=0;i<n;i++){
    print_out(i);
  }
  return 0;
}