#include <stdio.h>
#define M 100000
#define N -1

struct Node{
int parent,left,right;
};
struct Node T[M];
int D[M];

void print(int u){
  int c,i;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("depth = %d, ",D[u]);

  if(T[u].parent == N){
    printf("root, ");
  }
  else if(T[u].left == N){
    printf("leaf, ");
  }
  else printf("internal node, ");

  printf("[");

  c=T[u].left;
  for(i=0;c!=N;i++){
    if(i!=0)printf(", ");
      printf("%d",c);
  c=T[c].right;
  }

  printf("]\n");

}

void setdepth(int u,int p){
  D[u]=p;
  if(T[u].right != N) setdepth(T[u].right,p);
  if(T[u].left != N) setdepth(T[u].left,p+1);
}

int main(){
  int i,j,n,o,p,q,r,l;

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

  for(i=0;i<n;i++){
    scanf("%d%d",&o,&p);
    for(j=0;j<p;j++){
      scanf("%d",&q);
      if(j==0)T[o].left=q;
      else T[l].right=q;
      l=q;
      T[q].parent=o;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].parent == N)r=i;
  }
  setdepth(r,0);

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

  return 0;
}


