#include <stdio.h>
#define MAX 100000

typedef struct node{
  int left;
  int right;
  int p;
}Node;

Node node[MAX];
int depth[MAX];

void depthSearch(int a, int b){
  depth[a] = b;
  if(node[a].left != -1)depthSearch(node[a].left,b+1);

  if(node[a].right != -1)depthSearch(node[a].right,b);
}

int main(){
  int n;
  int id;
  int k;
  int c;
  int l;
  int a;
  int i , j;

  scanf("%d",&n);
    for(i = 0 ; i < n ; i++){
    node[i].p = -1;
    node[i].left = -1;
    node[i].right = -1;
  }

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

    if(k != 0){
      for(j = 0 ; j < k ; j++){
        scanf("%d",&c);
        if(j == 0)node[id].left = c;
        else{
          node[l].right=c;
        }
        l=c;
        node[l].p = id;
      }
    }
  }

  for(i = 0 ; i < n ; i++){
    if(node[i].p == -1)depthSearch(i,0);
  }

  for(i = 0 ; i < n ; i++){
    printf("node %d: parent = %d, depth = %d, ",i,node[i].p,depth[i]);

    if(node[i].p == -1){
      printf("root, ");
      printf("[");
      for(j = 0 , a=node[i].left ; a !=-1 ; a =node[a].right ,j++){
        if(j == 0)printf("%d",a);
        else printf(", %d",a);
      }
      printf("]\n");
    }

    else if(node[i].left == -1){
      printf("leaf, ");
      printf("[]\n");
    }

    else {
      printf("internal node, ");
      printf("[");

      for(j = 0 , a=node[i].left ; a != -1 ; a=node[a].right , j++){
        if(j == 0)printf("%d",a);
        else printf(", %d",a);
      }
      printf("]\n");
    }
  }
  return 0;
}

