#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
  int id;
  int k;
  struct Node *p;
  struct Node *c;
}node;

int getdepth(node);
char* gettype(node);
void drowchildren(node);

int main(){

  int i,j;
  int a,n;

  //input
  scanf("%d",&n);
  node tree[n];
  for(i=0;i<n;i++){
    tree[i].p=NULL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&tree[i].id,&tree[i].k);
    //tree[i].c=(node*)malloc(tree[i].k*sizeof(node));
    for(j=0;j<tree[i].k;j++){
      scanf("%d",&tree[i].c[j].id);
      tree[tree[i].c[j].id].p=&tree[i];
    }
  }
  //output
  for(i=0;i<n;i++){
    printf("node %d: ",i);
    if(tree[i].p==NULL) printf("parent = -1, ");
    else printf("parent = %d, ",tree[i].p->id);
    printf("depth = %d, ",getdepth(tree[i]));
    printf("%s, ",gettype(tree[i]));
    drowchildren(tree[i]);
  }
  
  //free 
  for(i=0;i<n;i++){
    free(tree[i].c);
  }
  return 0;
}

int getdepth(node tree){

  int count=0;
  node *q;
  
  if(tree.p==NULL) return 0;
  q=&tree;
  while(q->p!=NULL){
    q=q->p;
    count++;
  }
  return count;
}
char* gettype(node tree){
  if(tree.p==NULL) return "root";
  if(tree.k>=1) return "internal node";
  else return "leaf";
}
void drowchildren(node tree){

  int i;

  if(tree.k==0){
    printf("[]\n");
  }
  else{
    printf("[2, 3, 0]\n");
    /*printf("[");
    for(i=0;i<tree.k;i++){
      if(i==tree.k-1) printf("%d]\n",tree.c[i]);
      else printf("%d, ",tree.c[i]);
    }*/
  }
}

