#include <stdio.h>
#include <stdlib.h>
#define MAX 100005
#define NIL -1

typedef struct Node{
  int dim;
  int *child;
  int p;
  int dep;
} node;

node tree[MAX];
void calcDep(int r){
  int i;
  for(i=0;i<tree[r].dim;i++){
    tree[tree[r].child[i]].dep+=1+tree[r].dep;

    calcDep(tree[r].child[i]);
  }
}

int main(){
  int n,i,j,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    tree[i].p=NIL;
    tree[i].dep=0;
  }
  for(k=0;k<n;k++){
    scanf("%d",&i);
    scanf("%d",&tree[i].dim);
    tree[i].child=(int *)malloc(sizeof(int)*tree[i].dim);
    for(j=0;j<tree[i].dim;j++){
      scanf("%d",&tree[i].child[j]);
      tree[tree[i].child[j]].p=i;
    }
  }
  for(i=0;i<n;i++){
    if(tree[i].p==NIL) k=i;
  }
  calcDep(k);
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,tree[i].p,tree[i].dep); 
    if(tree[i].p==NIL){
      printf("root, [");
      for(j=0;j<tree[i].dim;j++){
	printf("%d",tree[i].child[j]);
	if(j!=tree[i].dim-1) printf(", ");
      }
    }
    else if(tree[i].dim==0){
      printf("leaf, [");
    }
    else{
      printf("internal node, [");
      for(j=0;j<tree[i].dim;j++){
	printf("%d",tree[i].child[j]);
	if(j!=tree[i].dim-1) printf(", ");
      }
    }
    printf("]\n");
  }
  return 0;
}

