#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#define lpton(i,n) for(int i=0;i<(int)n;i++)
#define lpto0(i,n) for(int i=n;i>-1;i--)
#define lpmn(i,m,n) for(i=m;i<n;i++)
#define ms(l,n,s) memset(l,n,s)
typedef struct rtree{
  int nnode;
  int nparent;
  int brn;
  int first;
  int last;
}rtree;
int dep;
void print(rtree*,int*,int);
int depth(rtree*,int);
char* type(rtree*,int);
int main(){
  int n,rn,cnt=0;
  int *cn;
  scanf("%d",&n);
  rtree *rt;
  rt=(rtree*)malloc(sizeof(rtree)*n);
  cn=(int*)malloc(sizeof(int)*n);
  ms(rt,-1,n*sizeof(rtree));
  lpton(i,n){
    scanf("%d",&rn);
    scanf("%d",&(rt+rn)->brn);
    (rt+rn)->nnode=rn;
    (rt+rn)->first=cnt;
    lpton(j,(rt+rn)->brn){
      scanf("%d",&*(cn+cnt));
      (rt+*(cn+cnt))->nparent=rn;
      cnt++;
    }
    (rt+rn)->last=cnt;
  }
  print(rt,cn,n);
  return 0;
}
void print(rtree *rt,int* cn,int n){
  int j,c;
  lpton(i,n){
    dep=0;
    printf("node %d: parent = %d, depth = %d, %s, [",(rt+i)->nnode,(rt+i)->nparent,depth(rt,i),type(rt,i));
    if((rt+i)->brn!=0)lpmn(j,(rt+i)->first,(rt+i)->last)printf("%d%s",*(cn+j),(j<(rt+i)->last-1)?", ":"]\n");
    else printf("]\n");
  }
}
int depth(rtree *rt,int i){
  if((rt+i)->nparent==-1)return dep;
  depth(rt,(rt+i)->nparent);
  return dep+=1;
}
char *type(rtree *rt,int i){
if((rt+i)->nparent==-1)return "root";
else if((rt+i)->brn==0)return "leaf";
else return "internal node";
}

