#include <stdio.h>
#define MAX 100000
typedef struct t{
  int p;
  int l;
  int r;
}tree;
int Depth(int);
void hantei(int,int,int);
tree T[MAX];
int cnt =0;
int main(){
  
  int n,k,i,j,id,c,l,num = 0;
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }
  for(i = 0;i < n;i++){
    scanf("%d",&id);
    scanf("%d",&k);
    for(j = 0;j < k;j++){
      scanf("%d",&c);
      //左右にわける
      if(j == 0){
	T[id].l = c;
      }
      //rightを兄弟として実装
      else{
	T[l].r = c;
      }
      l = c;
      T[c].p = id;
    }
  }
  for(i = 0;i < n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,Depth(i));
    hantei(T[i].p,i,n);
    printf("\n");
  }
  return 0;
}
int Depth(int x){
  int d = 0;
  while(T[x].p != -1){
    x = T[x].p;
    d++;
  }
  return d;
}

void hantei(int p,int node,int n){
  int i,j,wr = 0,x;
  if(p == -1){
    printf("root, ");
    printf("[");
      for(x = T[node].l;x != -1;x = T[x].r){
	if(wr)printf(", ");
	wr++;
	printf("%d",x);
	/*if(T[i].p == node && T[i].num == cnt){
	  if(wr)printf(", ");
	  wr++;
	  printf("%d",i);
	  cnt++;
	}
	*/
      }
    printf("]");
    return;
  }
  if(T[node].l == -1){
    printf("leaf, ");
    printf("[]");
  }
  else{
    printf("internal node, ");
    
    printf("[");
    for(x = T[node].l;x != -1;x = T[x].r){
      if(wr)printf(", ");
      wr++;
	printf("%d",x);
	/*if(T[i].p == node && T[i].num == cnt){
	  if(wr)printf(", ");
	  wr++;
	  printf("%d",i);
	  cnt++;
	*/
	}
    printf("]");
  }
}

