#include <stdio.h>
#define N 100000

typedef struct{
  int id;
  int k;
  int c[20];
  int p;
  int d;
  int type;
  int flag;
}Node;
Node node[N];

int main(){
  int i,j,k,n,tmp;
  
  scanf("%d",&n);
  if(n<0 || n>100001){
    printf("Error\n");
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&node[i].id);
    scanf("%d",&node[i].k);
    for(j=0;j<node[i].k;j++){
      scanf("%d",&node[i].c[j]);
    }
    node[i].flag = 0;
  }
  
  /*Search parent*/
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      for(k=0;k<node[j].k;k++){
	if(node[i].id == node[j].c[k]){
	  node[i].p = node[j].id;
	  node[i].flag = 1;
	  break;
	}
      }
    }
    if(node[i].flag == 0)  node[i].p = -1;
  }
          /*Search depth*/
  for(i=0;i<n;i++){
    tmp = node[i].p;
    node[i].d = 0;
    //printf("tmp: %d\n",tmp);
    if(tmp == -1) continue;
    while(1){
      if(tmp != -1){
	node[i].d++;
	tmp = node[tmp].p;
      }
      if(tmp == -1){
	break;
      }
    }
  }
       /*Judge type*/
  for(i=0;i<n;i++){
    if(node[i].p == -1) {
      node[i].type = -1;
      continue;
    }
    if(node[i].c[0] > 0){
      node[i].type = 1;
    }
    else node[i].type = 2;
  }
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,node[i].p,node[i].d);
    if(node[i].type == -1) printf("root, [");
    else if(node[i].type == 1) printf("internal node, [");
    else printf("leaf, [");
    for(j=0;j<node[i].k;j++){
      if(j == 0){
	printf("%d",node[i].c[0]);
	continue;
      }
      if(j < node[i].k){
	printf(", %d",node[i].c[j]);
      }
    }
    printf("]\n");
  }
  return 0;
}


