#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) memset(l,n,sizeof(l))
typedef struct{
  int nnode;
  int nparent;
  int brn;
  int cn[100000];
}rtree;
int dep;
void print(rtree*,int);
int depth(rtree*,int);
char* type(rtree*,int);
int main(){
  int n,cn,rn;
  rtree rt[100001];
  scanf("%d",&n);
  ms(rt,-1);
  lpton(i,n){
    scanf("%d",&rn);
    scanf("%d",&rt[rn].brn);
    rt[rn].nnode=rn;
    lpton(j,rt[rn].brn){
      scanf("%d",&rt[rn].cn[j]);
      rt[rt[rn].cn[j]].nparent=rn;
    }
  }
  print(rt,n);
  return 0;
}
void print(rtree *rt,int n){
  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)lpton(j,rt[i].brn)printf("%d%s",rt[i].cn[j],(j<rt[i].brn-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";
}

