#include <stdio.h>

#define NIL -1

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

struct Node L[100005];
int n;
int data[100005];


int dep( int o, int u)
{
  data[o] = u;
  if( L[o].right != NIL )dep(L[o].right, u);
  if( L[o].left != NIL )dep(L[o].left, u+1);
}

void print(int o)
{
  int i;
  int z;
  
    printf("node %d: parent = %d, depth = %d,",o,L[o].parent,data[o]);
    if( L[o].parent == NIL )printf(" root, ");
    else if( L[o].left == NIL )printf(" leaf, ");
    else printf(" internal node, ");
    printf("[");
    
for( i = 0 , z = L[o].left ; z != NIL ; i++, z = L[z].right){
  if(i) printf(", ");
  printf("%d",z);
 }
 
 printf("]");
 printf("\n");
}


int main()
{
int i,n,j,d,r,l,c,v;
  scanf("%d",&n);
  for( i = 0 ; i < n ; i++)
    L[i].parent = L[i].left = L[i].right = NIL;
  
  for( i = 0 ; i < n ; i++){
    scanf("%d%d",&v,&d);
    for( j = 0; j < d; j++){
      scanf("%d",&c);
      if( j == 0 )L[v].left = c;
      else L[l].right = c;
      l = c;
      L[c].parent = v;
    }
  }
  for( i = 0 ; i < n ; i++){
    if(L[i].parent == NIL) r=i;
  }

  dep(r,0);
  for( i = 0 ; i < n ; i++)print(i);

  return 0;
}

