#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char root[]="root";
char leaf[]="leaf";
char inter[]="internal node";
struct LIST{
  int key;
  struct LIST *next;
};
struct node{
  int parent;
  int depth;
  int degree;
  char type[15];
};
struct node tree[100];
struct LIST *list[100];
void push(int x,int node_num);
void print_list(int i);
void push(int x,int node_num){
  struct LIST *new_r,*tail;
  tail=NULL;
  if(list[node_num]==NULL){
    new_r=(struct LIST *)malloc(sizeof(struct LIST));
    new_r->key=x;
    new_r->next=NULL;
    list[node_num]=new_r;
    tail=new_r;
  }
  else {
    new_r=(struct LIST *)malloc(sizeof(struct LIST));
    new_r->key=x;
    tail->next=new_r;
    new_r->next=NULL;
    tail=new_r;
  }
}
void print_list(int i){
  struct LIST *node;
  if(list[i]==NULL){
    printf("[]\n");
    return ;
  }
  printf("[");
  for(node=list[i];node->next!=NULL;node=node->next){
    printf("%d, ",node->key);
  }
  printf("%d",node->key);
  printf("]\n");
}
void init(int n){
  int i;
  for(i=0;i<n;i++){
    list[i]=NULL;
    tree[i].depth=0;
    tree[i].parent=-1;
  }
}
 
int main(){
  int i,j,n;
  int degree;
  int x;
  int node_num, Root;
  scanf("%d",&n);
  init(n);
  for(i=0;i<n;i++){
    scanf("%d",&node_num);
    scanf("%d",&degree);
    tree[node_num].degree=degree;
    for(j=0;j<degree;j++){
      scanf("%d",&x);
      push(x,node_num);
      tree[x].parent=node_num;
    }
  }
  for(i=0;i<n;i++){
    if(tree[i].parent==-1)  {
      Root=i;
       strcpy(tree[i].type,root);
    }
    else if(list[i]==NULL) strcpy(tree[i].type,leaf);
     else strcpy(tree[i].type,inter);
  }
   for(i=0;i<n;i++){
   for(j=i;j!=Root;j=tree[j].parent)tree[i].depth++;
  }
   
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, %s, ",i,tree[i].parent,tree[i].depth,tree[i].type);
    print_list(i);
    printf("\n");
  }
  return 0;
}