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

int hukasa(int,int);

typedef struct node{
  int pa;
  int le;
  int ri;
}TREE;

TREE tree[100000];
int n,depth[100000];

int main(){
  int i,j,node,child,number,sub,root,numchild;
  scanf("%d",&n);
  if(n>100000) exit(2);
  for(i=0;i<n;i++) {
    tree[i].pa=tree[i].le=tree[i].ri=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&node,&child);
    for(j=0;j<child;j++){
      scanf("%d",&number);
      tree[number].pa=node;
      if(j==0) tree[node].le=number;
      else tree[sub].ri=number;
      sub=number;
    }
  }
  for(i=0;i<n;i++){
    if(tree[i].pa==-1) root=i;
  }

  hukasa(root,0);
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,tree[i].pa,depth[i]);
    if(tree[i].pa == -1) printf("root, [");
    else if(tree[i].le != -1)printf("internal node, [");
    else printf("leaf, [");
    
    numchild=tree[i].le;
    for(j=0;numchild != -1;j++){
      if(j>0)printf(", ");
      printf("%d",numchild);
      numchild=tree[numchild].ri;
    }
    printf("]\n");
  }
  return 0;
}

int hukasa(int u,int p){
  depth[u]=p;
  if(tree[u].ri != -1) hukasa(tree[u].ri,p);
  if(tree[u].le != -1) hukasa(tree[u].le,p+1);
}

