#include <stdio.h>
#define N 100005
#define Q -1
typedef struct{
  int p;
  int l;
  int r;
}Tree;
Tree tree[N];
int Deep[N];
void print(int x);
void de(int x, int p);

int main()
{
  int i,j,n,d,v,c,l,r;
  int deep,node,parent,depth;
  scanf ("%d",&n);

  for (i=0;i<n;i++){
    tree[i].p=Q;
    tree[i].l=Q;
    tree[i].r=Q;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0){
	tree[v].l=c;

      }else{
	  tree[l].r=c;
      }
	l=c;
	tree[c].p=v;
    }
  }
	
    for(i=0;i<n;i++){
      if(tree[i].p==Q)
	r=i;
    }

    de(r,0);

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

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

    printf("[");

    for(i=0,c=tree[x].l;c!=Q;i++,c=tree[c].r){
      if(i)
	printf(", ");
      printf("%d",c);
    }
    printf("]\n");
  }

 void de(int x, int p){
    Deep[x]=p;
    if (tree[x].r!=Q)//*同じ深さ設定*//
      de(tree[x].r,p);
    if (tree[x].l!=Q)//*左に+1*//
      de(tree[x].l,p+1);
  }
    
	
    


