#include <stdio.h>

int dep(int u,int k);
void print(int u);

typedef struct Node{
  int parent;
  int left;
  int right;
} node;
  
node T[100000];
int n,Dp[100000];

int main(){
  int i,j,dg,v,c,left,right;

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

  dep(right,0);

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

  return 0;
}

int dep(int u,int k){
  
  Dp[u]=k;
  if(T[u].right!=-1) dep(T[u].right,k);
  if(T[u].left!=-1) dep(T[u].left,k+1);
}

void print(int u){

  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("depth = %d, ",Dp[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");
}