#include<stdio.h>
#define N 100001
int depth(int);
struct Node{
  int p;
  int l;
  int r;
};
struct Node Tree[N];
 
 
int main()
{
 
  int i,j,n,par,child,sib,k,x;
 
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    Tree[i].p = -1;
    Tree[i].l = -1;
    Tree[i].r = -1;
  }
 
  for(i = 0; i < n; i++){
    scanf("%d %d",&par,&k);
    for(j = 0; j < k; j++){
      scanf("%d",&child);
      if(j == 0){
	Tree[par].l = child;
	Tree[child].p = par;
	x = child;
      }
      else {
	Tree[x].r = child;
	Tree[child].p= par;
	x = child;
      }
    }
  }
 
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ",i , Tree[i].p,depth(i));
    if(Tree[i].l  == -1 && Tree[i].p != -1)printf("leaf, ");
    else if(Tree[i].p == -1)printf("root, ");
    else if(Tree[i].l != -1)printf("internal node, ");
    printf("[");
 
    if(Tree[i].l != -1){
      printf("%d",Tree[i].l);
 
      sib = Tree[i].l;
 
      while(1){
	if(Tree[sib].r == -1)break;
	printf(", %d",Tree[sib].r);
	sib = Tree[sib].r;
      }
    }
    printf("]\n");
  }
 
  return 0;
}
 
int depth(int k){
  int dep =0;
  for(dep = 0; Tree[k].p != -1; dep++){
    k = Tree[k].p;
  }
  return dep;
}