#include<stdio.h>
#include<stdlib.h>

#define MAX 100001
#define NONUM -1

typedef struct{
  int p,l,r;
}Node;

Node A[MAX];
int n;

int depth(int u){
    int d=0;
    int tmp=A[u].p;
    while( tmp!=NONUM){ d++; tmp=A[tmp].p; }
    return d;
}
    
int print(int u){
    int tmp=A[u].l;
    int flg=0;
    printf("node %d: parent = %d, depth = %d, ", u, A[u].p, depth(u));
    if( A[u].p==NONUM) printf("root, [");
    else if( A[u].l!=NONUM ) printf("internal node, [");
    else printf("leaf, [");
    while( tmp!=NONUM ){
        if( flg==0 ){ printf("%d",A[u].l); flg=1;}
        else printf(", %d", tmp);
        tmp=A[tmp].r;
    }
    printf("]\n");
    return 0;
 
}

int main(void){
  int i,j,left,right,v,d,c,tmp;
  scanf("%d",&n);
  
  for(i=0;i<n;i++) A[i].p=A[i].l=A[i].r=NONUM;

  for(i=0;i<n;i++){
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      A[c].p=v;
      if(j==0) A[i].l=c;
      else A[i].r=c;
      tmp=c;
    }


  }

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