#include<stdio.h>
#define NIL -1
int getDepth(int);

typedef struct n{
    int parent;
    int left;
    int right;
    int depth;
}Node;

Node T[10000];

int main(){
    int n,i,j,id,k,c,cr;

    scanf("%d",&n);

    for(i=0;i<n;i++){
        T[i].parent=NIL;
        T[i].left=NIL;
        T[i].right=NIL;
    }

        
    for(i=0;i<n;i++){
      scanf("%d",&id);
      scanf("%d",&k);
    
      for (j = 0; j < k; j++)
      {
          if (j == 0)
          {
              scanf("%d",&c);
              T[id].left = c; 
              T[c].parent = id; 
          }
          else
          {
              scanf("%d",&cr);
              T[c].right = c;      
              T[cr].parent = id; 
                c = cr;
          }
      }
    }
    
    for(i=0;i<n;i++){
      printf("node %d:",i);
      printf("　parent = %d,",T[i].parent);
      printf("　depth = %d,",getDepth(i));

    if(T[i].parent==NIL && T[i].left==NIL){
        printf(" root, []\n");
     }
    else if(T[i].parent==NIL){
	printf("　root, [%d",T[i].left);
	for (j = T[T[i].left].right; j != NIL; j = T[j].right)
	  {
	    printf(", %d",j);
	  }
	printf("]\n");
      }
      else if (T[i].left != NIL)
	{
	  printf("　internal node, [%d", T[i].left);
	  for (j = T[T[i].left].right; j != NIL; j = T[j].right)
	    {
	      printf(", %d", j);
	    }
	  printf("]\n");
	}
      else
	{
	  printf("　leaf, []\n");
	}
    }
    return 0;
}

int getDepth(int i){
  int d=0;
  while(T[i].parent!=NIL){
    i=T[i].parent;
    d++;
  }
  return d;
}

