#include<stdio.h>

#define MAX 100005
#define NTL -1

struct Node{int p, l, r;};
struct Node A[MAX];

int n,H,D[MAX];

int main(){
  int i,j,d,v,c,l;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    A[i].p = A[i].l = A[i].r = NTL;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j == 0)A[v].l =c;
      else A[l].r =c;
      l =c;
      A[c].p=v;
    }
  }

  H=0;
  for(i=0;i<n;i++){
    D[i]=getDepth(i);
    if(D[i] >H)
      H=D[i];
  }

  for(i=0;i<n;i++)print(i);
  return 0;
}

int getDepth(int x){
  int d=0;

  for(;A[x].p!= NTL;d++)x = A[x].p;
  return d;
}

int print(int x){
  int i,c;

  printf("node %d: ",x);
  printf("parent = %d, ",A[x].p);
  printf("depth = %d, ",D[x]);

  if(A[x].p == NTL)printf("root, ");
  else if(A[x].l == NTL)printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i=0,c=A[x].l;c != NTL;i++,c = A[c].r){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}


