#include <stdio.h>
#define N 100000

typedef struct{
  int id;
  int p;
  int c;
} Tree;

int n;
Tree T[N];
int child[N][N];

int getdepth(int u){

  int d = 0;

  while(T[u].p >= 0){
    u = T[u].p;
    d++;
  }
  return d;
}

void print(void){

  int i,j,flag=0;

  for(i=0;i<n;i++){
    flag=0;

    printf("node %d: parent = %d, depth = %d, ",T[i].id,T[i].p,getdepth(i));
    if(T[i].c == 0 && T[i].p != -1)
      printf("leaf, [");
    else if(T[i].c != 0 && T[i].p != -1)
      printf("internal node, [");
    else 
      printf("root, [");

    for(j=0;j<T[i].c;j++){
      if(flag==0){ 
	printf("%d",child[i][j]);
	flag=1;
      }
      else {
	printf(", %d",child[i][j]);
      }
    }
    printf("]\n");
  }
}


int main(void){

  int i,j,node,deg;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].id = T[i].p = T[i].c = -1;    
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&node,&deg);
    T[node].id = node;
    T[node].c = deg;
    for(j=0;j<deg;j++){
      scanf("%d",&child[i][j]);
      T[child[i][j]].p = node;
    } 
  }
  print();
  return 0; 
}