#include<stdio.h>
#include<stdlib.h>

typedef struct d{
  int p;
  int d;
  int k;
  int *key;
}data;

data *tree;

void dataprinter(data out){
  puts("-----data-----");
  printf("p=%d d=%d k=%d\n",out.p, out.d, out.k);
  for(int i=0; i<out.k; i++){
    printf("%d ",out.key[i]);
  }
  printf("\n");
  puts("=====data=====");
}

void init(int n){
  int i;
  for(i=0; i<n; i++){
    tree[i].p = -1;
    tree[i].d = 0;
    tree[i].k = 0;
  }
}

void makeroot(){
  int i, id, n;
  scanf("%d ",&id);
  tree[id].p = -1;
  tree[id].d = 0;
  scanf("%d ",&tree[id].k);

// printf("tree.k %d\n",tree[id].k);

  tree[id].key = (int *)malloc(sizeof(int) * tree[id].k);
  for(i=0; i<tree[id].k; i++){
    scanf("%d ",&tree[id].key[i]);

    // printf("key %d\n",tree[id].key[i]);

    tree[tree[id].key[i]].p = id;
    tree[tree[id].key[i]].d = tree[id].d + 1;
   }

// dataprinter(tree[0]);
}

void maketree(){
  int i, id;

  scanf("%d ",&id);
  scanf("%d ",&tree[id].k);
  tree[id].key = (int *)malloc(sizeof(int) * tree[id].k);
  for(i=0; i<tree[id].k; i++){
    scanf("%d",&tree[id].key[i]);
    tree[tree[id].key[i]].p = id;
    tree[tree[id].key[i]].d = tree[id].d + 1;
  }
}

void printer(int n){
  int i,j;

  for(i=0; i<n; i++){
    printf("node %d: parent = %d, depth = %d, ",i, tree[i].p, tree[i].d);
    if(tree[i].d == 0){
      printf("root, [");
      for(j=0; j<tree[i].k; j++){
        printf("%d",tree[i].key[j]);
        if(j != tree[i].k-1) printf(", ");
      }
      printf("]\n");
    }
    else if(tree[i].k == 0){
        printf("leaf, []\n");
    }
    else{
      printf("internal node, [");
      for(j=0; j<tree[i].k; j++){
        printf("%d",tree[i].key[j]);
        if(j != tree[i].k-1) printf(", ");
      }
      printf("]\n");
    }
  }

}

int main(){
  int i, n;

  scanf("%d",&n);
  tree = (data *)malloc(sizeof(data) * n);
  init(n);
  // makeroot();
  for(i=0; i<n; i++){
    maketree();
  }
  printer(n);

  return 0;
}

