#include <stdio.h>
#define M 100000
#define NUL -1

struct node{int x,y,z;};
struct node s[M];

int r[M];

void hyouzi(int i){
  int j,c;
  printf("node %d: parent = %d, depth = %d, ",i,s[i].x,r[i]);

  if(s[i].x==NUL) printf("root, ");
  else if(s[i].y==NUL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(j=0,c=s[i].y;c!=NUL;j++,c=s[c].z){
    if(j>0) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void deep(int i,int x) {
  r[i]=x;
  if(s[i].z!=NUL) deep(s[i].z,x);
  if(s[i].y!=NUL) deep(s[i].y,x+1);
}

int main()
{
  int a,i,j,k,y,z,num,ch;

  scanf("%d",&k);

  for(i=0;i<k;i++){
    s[i].x=s[i].y=s[i].z=-1;
  }

  for(i=0;i<k;i++){
    scanf("%d%d",&num,&ch);
    for(j=0;j<ch;j++){
      scanf("%d",&a);
      if(j==0) s[num].y=a;
      else s[y].z=a;
      y=a;
      s[a].x=num;
    }
  }

  for(i=0;i<k;i++){
    if(s[i].x==NUL) z=i;
  }

  deep(z,0);

  for(i=0;i<k;i++) hyouzi(i);
  
  return 0;
}


