
#include<stdio.h>

typedef struct{
  int parent;
  int left;
  int right;
} tree;
tree t[1000000];

int main(){
  int a,b,c,id,k,m,depth = 0;
  int h[100000];
  scanf("%d",&a);


  for(b = 0; b < a; b++){
    t[b].parent = -1;
    t[b].left = -1;
    t[b].right = -1;
  }

  for(b = 0; b < a; b++){
    scanf("%d%d",&id,&k);
    for(c = 0; c < k; c++){
      scanf("%d",&h[c]);
      if(c == 0){
	t[h[0]].parent = id;
	t[id].left = h[0];
      }else{
	t[h[c]].parent = id;
	t[h[c-1]].right = h[c];
      }
    }
  }
  
  for(b = 0; b < a; b++){
    printf("node %d: parent = %d,",b,t[b].parent);
    m = b;
    while(t[m].parent != -1){
      depth++;
      m = t[m].parent;
    }
    printf(" depth = %d,",depth);
    depth = 0;
    if(t[b].parent == -1 && t[b].left == -1){
      printf(" root, []\n");
    }
    else if(t[b].parent == -1 && t[b].left != -1){
      printf(" root, [%d",t[b].left);
      for(c = t[t[b].left].right;c!=-1;c = t[c].right){
	printf(", %d",c);
      }
      printf("]\n");
    }

    else if(t[b].left!=-1){
      printf(" internal node, [%d",t[b].left);
      for(c = t[t[b].left].right;c!=-1;c=t[c].right){
	printf(", %d",c);
      }
      printf("]\n");
    }


    else{
      printf(" leaf, []\n");
    }
  }

  return 0;
}

