#include<stdio.h>
#define NIL -1

typedef struct{
  int depth;
  int parent;
  int left_leaf;
  int sibling;
}node;
 
node A[100000];
int n;

int depth(int now){
  int dep=0;
  while(1){
    if(A[now].parent==NIL)return dep;
    else {
      now=A[now].parent;
      dep++;
    }
  }
}

void init(){
  int i;
  for(i=0;i<n;i++){
    A[i].parent=NIL;
    A[i].left_leaf=NIL;
    A[i].sibling=NIL;
  }
  return;
}

int main(){
  int i,j,now,leaf,k;
  
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%d",&now);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&leaf);
      if(j==0){
	A[now].left_leaf=leaf;
	A[leaf].parent=now;
      }
      else {
	A[now].sibling=leaf;
	A[leaf].parent=A[now].parent;
      }   
      now=leaf;
    } 
  } 
  for(i=0;i<n;i++){
    A[i].depth=depth(i);
  } 
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,A[i].parent,A[i].depth);
    if(A[i].parent==NIL)printf("root, ");
    else if(A[i].left_leaf==NIL)printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    for(j=A[i].left_leaf;j!=NIL;j=A[j].sibling){
      if(j==A[i].left_leaf)printf("%d",j);
      else printf(", %d",j); 
    }
    printf("]\n"); 
  }
  return 0;
}