#include <stdio.h>
#include <string.h>
#define MAX 80000
typedef struct {
  int parent;
  int id;
  int chc;
  int chil[220];
  
}Node;
  
Node tree[MAX];
int CH[MAX];
int n;
void createnode(int);
void printtree(int);
int s_dep(int,int,int);
int main(){

  int i,t,id,deg;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    tree[i].parent=-1;
    tree[i].id=-1;
    tree[i].chc=-1;

}

  for(i=0;i<n;i++){
    scanf("%d%d",&id,&deg);
    tree[id].chc=deg;
    for(t=0;t<deg;t++){
      scanf("%d",&CH[t]);
      tree[CH[t]].parent=id;
      tree[id].chil[t]=CH[t];
    }    
  }

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

void printtree(int id){
  int i,chc;
  chc=tree[id].chc;
  printf("node %d: ",id);
  printf("parent = %d, ",tree[id].parent);
  printf("depth = %d, ",s_dep(id,0,id));
  if(tree[id].parent==-1) printf("root, [");
  else if(tree[id].chc>0) printf("internal node, [");
  else printf("leaf, [");
  for(i=0;i<chc;i++){
    printf("%d",tree[id].chil[i]);
    if(i<chc-1)printf(", ");
  }
  printf("]\n");
  





}


int s_dep(int id,int de,int num){
  int i;

  if(tree[num].parent!=-1) de = s_dep(id,de+1,tree[num].parent);
  else return de;

}