#include<stdio.h>
#define N 100001

int depth(int);
struct Node{
  int p;
  int l;
  int r;
};
struct Node tree[N];

int main(){
  int i,j,n,k,x=0,parent=0,kids=0,sibuya=0;

   scanf("%d",&n);
   for(i=0;i<n;i++){
     tree[i].p=-1;
     tree[i].l=-1; 
     tree[i].r=-1;
   }

  
  for(i = 0; i < n; i++){
    scanf("%d %d",&parent,&k);
    for(j = 0; j < k; j++){
      scanf("%d",&kids);
      if(j == 0){
    tree[parent].l = kids;
      tree[kids].p = parent;
      x = kids;
      }
      else {
    tree[x].r = kids;
    tree[kids].p= parent;
    x = kids;
      }
    }
  }

   for(i=0;i<n;i++){
     printf("node %d: parent = %d, depth = %d, ",i,tree[i].p,depth(i));
     if(tree[i].l == -1 && tree[i].p != -1)printf("leaf, ");
     else if(tree[i].p==-1)printf("root, ");
     else if(tree[i].l != -1)printf("internal nade, ");
     printf("[");

     if(tree[i].l != -1){
       printf("%d",tree[i].l);
       sibuya = tree[i].l;

       while(1){
	 if(tree[sibuya].r ==-1)break;
	 printf(", %d",tree[sibuya].r);
	 sibuya=tree[sibuya].r;
       }
     }
     printf("]\n");
   }
   return 0; 
}

int depth(int k){
  int dep =0;
  for(dep=0;tree[k].p!=-1;dep++){
    k=tree[k].p;
  }
  return dep;
}