#include<stdio.h>
#define N 100000

typedef struct{
  int parent;
  int left;
  int right;
}node;

node T[N];
int c[N];
int n;

int Depth(int );
void Judge(int );
void print(int );

int main(){
  int i,j;
  int id,k,z;
  int child,lastchild;

  scanf("%d",&n);
  for(i=0 ;i<n ;i++){
    T[i].parent = -1;
    T[i].right = -1;
    T[i].left = -1;
  }

  for(i=0 ; i<n ; i++){
    scanf("%d%d",&id,&k);

    for(j=0 ; j<k ; j++){
      scanf("%d",&child);
      T[child].parent = id;
      if(j == 0) T[id].left=child;
      else T[lastchild].right=child;
      lastchild = child;

    }
  }

  for(i=0 ; i<n ; i++){
    z=Depth(i);
    printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,z);
    Judge(i);
  }

  return 0;
}


int Depth(int i){
  int count = 0;

  while(1){
    if(T[i].parent == -1) break;
    i=T[i].parent;
    count++;
  }
  return count;
}


void Judge(int i){
  int t;

  if(T[i].parent == -1) printf("root, [");
  else if(T[i].left == -1) printf("leaf, [");
  else printf("internal node, [");
  print(T[i].left);
  printf("]\n");
}

void print(int i){
  if(i == -1) return;
  if(T[i].right == -1)printf("%d",i);
  else
    {
      printf("%d, ",i);
      print(T[i].right);
    }
}