#include<stdio.h>

#define MAX 10005
#define ZERO -1 //親なし

typedef struct Node{
  int parent; 
  int left;
  int right;
}Tree;

Tree tree[MAX];

void Treeprint(int); //print関数

int main(){
  int n; //節点の個数
  int i,j; //ループカウンタ
  int id,k,child; //
  int l;

  scanf("%d", &n); //個数入力

  for(i = 0;i < n;i++){
    tree[i].parent = tree[i].left = tree[i].right = ZERO; //初期化
  }
  
  for(i = 0;i < n;i++){
    scanf("%d%d",&id,&k); //id・kの入力
    
    for(j = 0;j < k;j++){
      scanf("%d",&child); //子供・葉の入力
      tree[child].parent = id; 

      if(j == 0){
	tree[id].left = child; //左下の子供
      }
      else if(j > 0){
	tree[l].right = child; //兄弟
      }
      l = child; //兄弟
    }
  }
  for(i = 0;i < n;i++){ //出力
    Treeprint(i);
  }
  return 0;
}

void Treeprint(int n){ 

  int i = tree[n].parent; //親idの代入
  int depth = 0;
  while(i != ZERO){
    i = tree[i].parent;
    depth++;
  }
  if(depth == 0){
    printf("node %d: parent = %d, depth = %d, root, ",n,tree[n].parent,depth);
  }
  else if(tree[n].left == ZERO){
    printf("node %d: parent = %d, depth = %d, leaf, ",n,tree[n].parent,depth);
  }
  else{
    printf("node %d: parent = %d, depth = %d, internal node, ",n,tree[n].parent,depth);
  }

  i = tree[n].left;
  printf("[");
  if(i != ZERO){ //兄弟の表示
    printf("%d",i);
  }
  while(i != ZERO){ 
    i = tree[i].right;

    if(i != ZERO){
      printf(", %d", i);
    }
  }
  printf("]\n");
}