#include<stdio.h>
#include<stdlib.h>
typedef struct S{
  int parent;
  int *d;
  int e;
}Node;

int depth();

int main(){
  int n,i,j,a,b,c;
  Node *node;
  scanf("%d",&n);
  node=(Node*)malloc(sizeof(Node)*n);
  for(i=0;i<n;i++){
    node[i].parent=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d",&a);
    scanf("%d",&b);
    node[a].d=(int*)malloc(sizeof(int)*b);
    node[a].e=b;
    for(j=0;j<b;j++){
      scanf("%d",&node[a].d[j]);
      node[node[a].d[j]].parent=a;
    }
  }
  for(i=0;i<n;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",node[i].parent);
    printf("depth = %d, ",depth(node,i));
    if(node[i].parent==-1){
      printf("root, ");
    }
    else if(node[i].e==0){
      printf("leaf, ");
    }
    else{
      printf("internal node, ");
    }
    printf("[");
    for(j=0;j<node[i].e;j++){
            printf("%d",node[i].d[j]);
            if(j!=node[i].e-1){
                printf(", ");
            }
        }
        printf("]\n");
    }
}
int depth(Node node[],int n){
    if(node[n].parent==-1){
        return 0;
    }
    return depth(node,node[n].parent)+1;
}

