#include <stdio.h>
#define N 100001

typedef struct{
  int par;
  int l_child;
  int r_sib;
}node;

node tree[N];

int depth(int);

int main(){
  int n,id,cnum,lef,child,i,j;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    tree[i].par = -1;
    tree[i].l_child = -1;
    tree[i].r_sib = -1;
  }
  
  for(i=0; i<n; i++){
    scanf("%d %d", &id, &cnum);
    for(j=0; j<cnum; j++){
      scanf("%d", &child);
      if(j == 0) tree[id].l_child = child;
      else tree[lef].r_sib = child;
      tree[child].par = id;
      lef = child;
    }
  }

  for(i=0; i<n; i++){
    printf("node %d: parent = %d, depth = %d, ", i, tree[i].par, depth(i));
    if(tree[i].par == -1) printf("root, [");
    else if(tree[i].l_child == -1) printf("leaf, [");
    else printf("internal node, [");
    lef = tree[i].l_child;
    for(j=0; ; j++){
      if(lef == -1) break;
      if(j != 0) printf(", ");
      printf("%d",lef);
      lef = tree[lef].r_sib;
    }

    printf("]\n");
  }
  

  
}

int depth(n){
  if(tree[n].par == -1) return 0;
  return depth(tree[n].par)+1;
}