#include<stdio.h>

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

Tree t[100000];
int num,dep[100000];

void print(int);
void rec(int,int);

int main(){
  int volume,k,l,r,c,i,j;

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

  for(i = 0; i< num; i++){
    scanf("%d%d",&volume,&k);
  
    for(j = 0;j < k; j++){
      scanf("%d",&c);
      if(j == 0)t[volume].left = c;
      else t[l].right = c;
      l = c;
      t[c].parent = volume;
    }
  }

  for(i = 0; i < num; i++){
    if(t[i].parent == -1)r = i;
  }
  rec(r,0);

  for(i = 0; i < num; i++){
    print(i);
  }

  return 0;
}


void print(int u){

  int i,c;
  printf("node %d: parent = %d: depth = %d, ",u,t[u].parent,dep[u]);
  if(t[u].parent == -1)printf("root, ");
  else if(t[u].left == -1)printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i = 0, c = t[u].left; c != -1; i++,c = t[c].right){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}


void rec(int u,int p){

  dep[u] = p;

  if(t[u].right != -1)rec(t[u].right,p);
  if(t[u].left != -1)rec(t[u].left,p+1);


}