#include<stdio.h>
#define N 100000

typedef struct{
  int pare,fstch,sibling;
}Node;

Node node[N];
int n,dep[N];

void print(int x){
  int i,ch;

  printf("node %d: parent = %d, depth = %d, ",x,node[x].pare,dep[x]);
  if(node[x].pare==-1) printf("root, ");
  else if(node[x].fstch==-1) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i=0,ch=node[x].fstch ; ch!=-1 ; i++,ch=node[ch].sibling){
    if(i>0)printf(", ");
    printf("%d",ch);
  }
  printf("]\n");
}

void depth(int x,int cnt){
  dep[x]=cnt;
  if(node[x].sibling != -1){
    depth(node[x].sibling,cnt);
  }
  if(node[x].fstch != -1){
    depth(node[x].fstch,cnt+1);
  }
}

int main(){

  int i,j,ch,v,digree,first,root,k;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    node[i].pare = node[i].fstch = node[i].sibling = -1;

  for(i=0;i<n;i++){
    scanf("%d %d",&v,&digree);

    for(j=0;j<digree;j++){
      scanf("%d",&ch);
      if(j==0)
	node[v].fstch=ch;
      else
	node[first].sibling=ch;
      first=ch;
      node[ch].pare=v;
    }
  }

  for(k=0;k<n;k++){
    if(node[k].pare==-1)
      root=k;
  }

  depth(root,0);

  for(i=0;i<n;i++) print(i);

  return 0;
}

