#include <stdio.h>

#define MAX 100000
#define NIL -1

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

Node tree[MAX];
int n,depth[MAX];

void print(int);
int getDepth(int);
int child[MAX];

int main(){

  int i,j;
  int number,degree;

  scanf("%d",&n);

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

  for(i=0; i<n; i++){
    scanf("%d %d",&number,&degree);

    for(j=0; j<degree; j++){
      scanf("%d",&child[j]);
    

    tree[child[j]].parent = number;

    if(j==0) tree[number].left = child[0];
    else tree[child[j-1]].right = child[j];

    }
  }

  for(i=0; i<n; i++){
    depth[i] = getDepth(i);
  }

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

  return 0;
}

int getDepth(int i){
  int a = 0;

  while(tree[i].parent >= 0){
    a++;
    i = tree[i].parent;
  }

  return a;
}

void print(int i){

  int a,count=0;

printf("node %d: parent = %d,depth = %d,",i,tree[i].parent,depth[i]);

if(tree[i].parent == NIL) printf("root,[");
 else if(tree[i].left == NIL) printf("leaf,[");
 else  printf("internal node,[");

 i = tree[i].left;
 while(i != NIL){
   if(count == 0)
     printf("%d",i);
   else
     printf(", %d",i);

 i= tree[i].right;
 count++;
 }

 printf("]\n");
}