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

#define N 100001

typedef struct{
  int p;
  int left;
  int right;
}Tree;

Tree T[N];
int depth(int);

int main(){
  int n,i,j,id,k,temp;

  scanf("%d ",&n);

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

  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      if(j==0){
        scanf("%d",&T[id].left);
        temp=T[id].left;
      }
      else{
        scanf("%d",&T[temp].right);
        temp=T[temp].right;
      }
T[temp].p=id;
    }

  }




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

      printf("[");
      if(T[i].left!=-1){
        printf("%d",T[i].left);
        temp=T[i].left;
        while(T[temp].right!=-1){
          printf(", %d",T[temp].right);
          temp=T[temp].right;
        }
      }
      printf("]\n");
  }
  return 0;
}

int depth(int id){
  int cnt=0;

  while(T[id].p!=-1){
    id=T[id].p;
    cnt++;
  }
  return cnt;
}

