#include<stdio.h>
#define MAX 1000000

typedef struct{

  int x,y,z;

}Tree;


Tree A[MAX];

int Dep(int);

main(){

  int i,j,n,num,deg,c,k=0;


  scanf("%d",&n);

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

    A[i].x = -1;
    A[i].y = -1;
    A[i].z = -1;
  }


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

    scanf("%d%d",&num,&deg);

    for(j = 0; j < deg; j++){

      scanf("%d",&c);

      if(j == 0)A[num].y = c;

      else A[k].z = c;

      k = c;
      A[c].x = num;

    }
  }


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

    printf("node %d: parent = %d, depth = %d,",i,A[i].x,Dep(i));

    if(Dep(i) == 0) printf(" root, [");

    else if(A[i].y == -1) printf(" leaf, [");

    else printf(", internal node, [");

    j = A[i].y;

    while(j != -1){

      printf("%d",j);

      j = A[j].z;

      if(j != -1){

	printf(", ");
      }
    }

    printf("]\n");
  }

  return 0;
}



int Dep(int num){

  int dep = 0;

  while(A[num].x != -1){

    num = A[num].x;
    dep++;
  }

  return dep;
}
      
	  
	

