#include <stdio.h>
#define MAX 100000

void Print(int);
int depth(int,int);

struct Node{
  int oya, ri,le;
};

struct Node Tree[MAX];
int Depth[MAX];

int main(){
  int n,i,j,num,d,c,l,r;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    Tree[i].oya=Tree[i].le=Tree[i].ri=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&num,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0) Tree[num].le=c;
      else Tree[l].ri=c;
      l=c;
      Tree[c].oya=num;
    }
  }
  for(i=0;i<n;i++){
    if(Tree[i].oya==-1) r=i;
  }
  depth(r,0);
  for(i=0;i<n;i++)Print(i);
  return 0;
}





void Print(int a){
  int i,b;

  printf("node %d: ",a);
  printf("parent = %d, ",Tree[a].oya);
  printf("depth = %d, ",Depth[a]);

  if(Tree[a].oya==-1) printf("root, ");
  else if(Tree[a].le==-1) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0,b=Tree[a].le;b != -1;i++,b=Tree[b].ri){
    if(i>0) printf(", ");
    printf("%d",b);
  }
  printf("]\n");
}




int depth(int a, int b){
  Depth[a]=b;
  if(Tree[a].ri !=-1) depth(Tree[a].ri, b);
  if(Tree[a].le !=-1) depth(Tree[a].le ,b+1);
  return 0;
}

