#include<stdio.h>
#define MAX 100005
 
typedef struct{
  int parent, left, right, depth;
}Node;
 
Node tree[MAX];
 
void print(int);
void getDepth(void);

int n,i;

int main(void){
  int k,j,rank,c,d,pre;
 
  scanf("%d",&n);
 
  for(i = 0; i < n; i++){
    tree[i].parent = tree[i].left = tree[i].right = -1;
  }
 
  for(i = 0; i < n; i++){
    scanf("%d%d",&rank ,&k);
    for(j = 0; j < k; j++){
      scanf("%d", &c);
       
      if(j == 0){
    tree[rank].left = c;
    tree[c].parent = rank;
    pre = c;
      }else{
    tree[pre].right = c;
    tree[c].parent = rank;
    pre = c;
      }
    }
  }

  getDepth();

  for(i = 0; i < n; i++){
    print(i);
  }

  return 0;
}

void print(int i){
  int left;

  printf("node %d: parent = %d, depth = %d, ",i,tree[i].parent,tree[i].depth);
  if(tree[i].parent == -1){
    if(tree[i].left == -1){
      printf("root, []\n");
    }else{   
      left = tree[i].left;
      printf("root, [");
      printf("%d",left);
      while(1){
	if(tree[left].right == -1){
	  break;
	}
	printf(", %d",tree[left].right);
	left = tree[left].right;
      }
      printf("]\n");
    }
  }else if(tree[i].parent != -1 && tree[i].left != -1){
    left = tree[i].left;
    printf("internal node, [");
    printf("%d",left);
    while(1){
      if(tree[left].right == -1){
	break;
      }
      printf(", %d",tree[left].right);
      left = tree[left].right;
    }
    printf("]\n");
  }else{
    printf("leaf, []\n");
  }
}

void getDepth(){
  int i,p;

  for(i = 0; i < n; i++){
    p = tree[i].parent;
    while(1){
      if(p == -1){
	break;
      }
      p = tree[p].parent;
      tree[i].depth++;
    }
  }
}