#include <stdio.h>

#define MAX 100005

struct Node
{

  int p;
  int l,r;
  
};

struct Node T[MAX];

void print();
int rec();

int n,A[MAX];


int main()
{
  int i,j;
  int a,b,c,l,r;

  scanf("%d",&n);
  
  for(i = 0;i < n; i++) {

    T[i].p = -1;
    T[i].l = -1; 
    T[i].r = -1;
    
  }
  
  for(i=0;i<n;i++){

    scanf("%d%d",&a,&b);

    for( j = 0 ; j < b ; j++){

      scanf("%d",&c);

      if(j == 0)T[a].l=c;      
      else T[l].r=c;
      
      l = c;
      T[c].p = a;
      
    }
  }
  
  for(i = 0;i < n; i++){
    if(T[i].p == -1) r = i;
  }
  
  rec(r,0);

  for(i=0;i<n;i++)
    print(i);
  
  return 0;
}

int rec(int x,int y){
  
  A[x] = y;
  if(T[x].r!=-1)rec(T[x].r,y);
  if(T[x].l!=-1)rec(T[x].l,y+1);
  
}
 
void print(int a){

  int i,u;

  printf("node %d:",a);
  printf(" parent = %d,",T[a].p);
  printf(" depth = %d,",A[a]);
  
  if(T[a].p == -1){
    printf(" root, ");
  }
  else if(T[a].l == -1){
    printf(" leaf, ");
  }
  else printf(" internal node, ");
  printf("[");
  
  for(i = 0,u =T[a].l; u != -1; i++,u = T[u].r){
    
    if(i)printf(", ");
    printf("%d",u);
    
  }

  printf("]");

  printf("\n");
}