#include<stdio.h>
#define MAX 100

typedef struct{
  int id;
  int k;
  int c[MAX];
  int p;
  int d;
  char *type;
}Tree;

int getParent(int);
Tree A[MAX];
int n;

int main()
{
  int i,j,k,l,hanntei;
  Tree tmp;
  /* 入力 */
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d%d",&A[i].id,&A[i].k);
    for(j = 0;j < A[i].k;j++){
      scanf("%d",&A[i].c[j]);
    }
  }
  

  for(i = 0;i < n;i++){
    hanntei = getParent(i);
    if(A[i].k == 0 && hanntei == 1){
      A[i].type = "leaf";
    }
    
    if(A[i].k > 0 && hanntei == 1){
      A[i].type = "internal node";
    }
    

    if(hanntei == 0){
      A[i].type = "root";
    }
  }


  for(i = 0;i < n;i++){
    if(i != A[i].id){
      for(j = 0;j < n;j++){
  	if(i == A[j].id){
  	  tmp = A[i];
  	  A[i] = A[j];
  	  A[j] = tmp;
  	}
      }
    }
  }

  for(i = 0;i < n;i++){
    printf("node %d: parent = %d, depth = %d, %s, [",A[i].id,A[i].p,A[i].d,A[i].type);
    if(A[i].c[0] == '\0')printf("]\n");
    else{
    for(j = 0;j < A[i].k - 1;j++){
      printf("%d, ",A[i].c[j]);
    }
    if(j == A[i].k - 1) printf("%d]\n",A[i].c[j]);
    }
  }
  
  return 0;
}  

int getParent(int i)
{
  int l,j,count = 0;  
  for(l = 0;l < n;l++){
    for(j = 0;j < A[l].k;j++){
      if(A[i].id == A[l].c[j]){
	A[i].p = A[l].id;
	A[i].d = A[l].d + 1;
	count = 1;
      }
    }
  }

  if(count == 0){
    A[i].p = -1;
    A[i].d = 0;
  }
  return count;
}