#include<stdio.h>
#define NO -1
#define MAX 1000000
typedef struct Node{
  int p,l,r;
}S;
S tree[MAX];
int getdepth(int x){
  int d=0;
  while(tree[x].p!=NO){
    x=tree[x].p;
    d++;
  }
  return d;
}
void out(int y){
  int i,j;
  printf("node %d: ",y);
  printf("parent = %d, ",tree[y].p);
  printf("depth = %d, ",getdepth(y));
  if(tree[y].p==NO)printf("root, ");
  else if(tree[y].l==NO)printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i=0,j=tree[y].l;j!=NO;i++,j=tree[j].r){
    if(i)printf(", ");
    printf("%d",j);
  }
  printf("]\n");
}
int main(){
  int n,i,j,a,b,m,z,l;
  scanf("%d",&n);
  for(i=0;i<n;i++)tree[i].p=tree[i].r=tree[i].l=NO;
  for(i=0;i<n;i++){
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&m);
      if(j==0)tree[a].l=m;
      else tree[l].r=m;
      l=m;
      tree[m].p=a;
    }
  }
  for(i=0;i<n;i++)out(i);
  return 0;
}

