#include <stdio.h>
#include <stdlib.h>

#define MAX 10000

typedef struct node{
  int id;
  int k;
  int p;
  int d;
  char *type;
  int c[MAX];
  struct node *par;
}Node;

void depthSearch(int,Node*);

Node node[MAX];

int main(){
  
  int n,i,j,l;
  
  //in
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&node[i].id,&node[i].k);
    
    for(j=0;j<node[i].k;j++){
      scanf("%d",&node[i].c[j]);
    }
  }
  
  //parentSearch
  for(i=0;i<n;i++){
    node[i].p = -1;
    node[i].d = 0;
    node[i].par = NULL;
    
    for(j=0;j<n;j++){
      for(l=0;l<node[j].k;l++){
	if(node[i].id == node[j].c[l]){
	  node[i].p = node[j].id;
	  node[i].par = &node[j];
	}
      }
    }
  }
  
  //depthSearch & typeJudge
  for(i=0;i<n;i++){
    depthSearch(i,&node[i]);
    
    if(node[i].p == -1) node[i].type = "root";
    else if(node[i].k == 0) node[i].type = "leaf";
    else node[i].type = "internal node";
  }
  //out
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, %s, [",
	   node[i].id,node[i].p,node[i].d,node[i].type);
    
    for(j=0;j<node[i].k;j++){
      if(j==0) printf("%d",node[i].c[j]);
      else printf(", %d",node[i].c[j]);
    }
    printf("]\n");
  }

  return 0;
}

void depthSearch(int i,Node* keyNode){
  if(keyNode->p != -1){
    node[i].d++;
    return depthSearch(i,keyNode->par);
  }
}