#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node {
  int p,r,l;
};

struct Node A[MAX];
int n,B[MAX];

void print(int x){
  int i,c;
 
  printf("node %d: ",x);
  printf("parent = %d, ",A[x].p);
  printf("depth = %d, ",B[x]);
	 
 if(A[x].p==NIL)printf("root, [");
 else if(A[x].l==NIL)printf("leaf, [");
else printf("internal node, [");

 for(i=0,c=A[x].l;c!=NIL;i++,c=A[c].r){
	   if(i!=0)printf(", ");
	   printf("%d",c);
	 }
	 printf("]\n");
	 }
	 
	 
    int depth(int x,int y){
    B[x]=y;
    if(A[x].r!=NIL)depth(A[x].r, y);
    if(A[x].l!=NIL)depth(A[x].l, y+1);
  }

  int main(){
    int i,j,d,v,c,l,r;

    scanf("%d",&n);
    
    for(i=0;i<n;i++)A[i].p=A[i].l=A[i].r=NIL;
    
    for(i=0;i<n;i++){
      scanf("%d %d",v,d);
      for(j=0;j<d;j++){
	scanf("%d",&c);
	if(j==0)A[v].l=c;
	else A[l].r=c;
	l=c;
	A[c].p=v;
      }
    }
    for(i=0;i<n;i++){
      if(A[i].p==NIL)r=i;
    }
    depth(r,0);

    for(i=0;i<n;i++)print(i);

    return 0;
  }

