#include <stdio.h>
#define N 100000

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

Node T[N];

int depth(int);
int degree(int);

int main()
{
  int n,i,j,id,d,c,k;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p = -1;
    T[i].r = -1;
    T[i].l = -1;
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&d);
    for(j=0;j<d;j++){
      scan("%d",&c);
      T[c].p = id;
      if(j==0){
	T[id].l = c;
      }
      else{
	T[k].r = c;
      }
      k = c;
    }
  }
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth(i));
    if(T[i].p==-1){
      printf("root, [");
    }
    else if(T[i].l==-1){
      printf("leaf, [");
    }
    else {
      printf("internal node, [");
    }
    degree(T[i].l);
    printf("]\n");
  }
  return 0;
}

int depth(int x)
{
  if(T[x].p == -1){
    return 0;
  }
  return 1 + depth(T[x].p;
}

int degree(int y)
{
  if(y==-1){
    return 0;
  }

  if(T[y].r==-1){
    printf("%d",y);
  }
  else{
    printf("%d, ",y);
    degree(T[y].r);
  }
}