#include <stdio.h>
#include <stdlib.h>
#define N 100000
#define NIL -1
typedef struct node{
  int parent;
  int right;
  int left;
}Tree;
Tree T[N];
int n,cnt[N];
void print(int u);
void rec (int u,int p){
  cnt[u]=p;
  if(T[u].right!=NIL){
    rec(T[u].right,p);
  }
  if(T[u].left!=NIL){
    rec(T[u].left,p+1);
  }

}
int main(){
  int i,j,d,k,children,number,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=T[i].left=T[i].right=NIL;

  }


  for(i=0;i<n;i++){
    scanf("%d%d",&number,&d);
    for(j=0;j<d;j++){
      scanf("%d",&children);
      if(j==0){
        T[number].left=children;
      }
      else {
        T[l].right=children;
      }
      l=children;
      T[children].parent=number;
    }
  }
  rec(r,0);
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}



void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("depth = %d, ",cnt[u]);

  if(T[u].parent==NIL){
    printf("root, ");
  }
  else if(T[u].left==NIL){
    printf("leaf, ");
  }
  else {printf("internal node, ");
  }
  printf("[");


  for(i=0,c=T[u].left;c!=NIL;i++,c=T[c].right){
    if(i){
      printf(", ");
    }
    printf("%d",c);
  }
  printf("]\n");
}