#include<stdio.h>
typedef struct{
  int p,l,r,d;
}Node;
Node A[100001];
int rec(int,int);
int main(){
  int n,k;
  int id,c,l,r,a;
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    A[i].p=A[i].l=A[i].r=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      if(j==0) A[id].l = c;
      else A[l].r = c;
      l = c;
      A[c].p = id;
    }
  }
  for(i=0;i<n;i++) if(A[i].p==-1) r = i;
  rec(r,0);
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,A[i].p,A[i].d);
    if(A[i].p==-1)printf("root, ");
    else if(A[i].l!=-1) printf("internal node, ");
    else printf("leaf, ");
    printf("[");
    if(A[i].l!=-1){
      printf("%d",A[i].l);
      a = A[i].l;
      while(1){
	if(A[a].r==-1) break;
	else printf(", %d",A[a].r);
	a = A[a].r;
      }
    }
    printf("]\n");
  }
  return 0;
}
int rec(int r,int p){
  A[r].d = p;
  if(A[r].r!=-1) rec(A[r].r,p);
  if(A[r].l!=-1) rec(A[r].l,p+1);
}

