#include<stdio.h>
#define MAX 100000
#define NIL -1

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

Node T[MAX];
int depth[MAX];

void print(int id){
  int i,left;
  printf("node %d: ",id);
  printf("parent = %d, ",T[id].p);
  printf("depth = %d, ",depth[id]);
  if(T[id].p == NIL) printf("root, ");
  else if(T[id].left == NIL) printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i = 0,left = T[id].left;left != NIL;++i,left = T[left].right){
    if(i) printf(", ");
    printf("%d",left);
  }
  printf("]\n");
}

void rec(int id ,int p){
  depth[id] = p;
  if(T[id].right != NIL){
    rec(T[id].right,p);
  }
  if(T[id].left != NIL){
    rec(T[id].left,p + 1);
  }
}

int main(){
  int k,id,c,left,root,n,i,j;
  scanf("%d",&n);
  for(i = 0;i < n;++i){
    T[i].p = T[i].left = T[i].right = NIL;
  }
  for(i = 0;i < n;++i){
    scanf("%d%d",&id,&k);
    for(j = 0;j < k;++j){
      scanf("%d",&c);
      if(j == 0){
        T[id].left = c;
      }
      else{
        T[left].right = c;
      }
      left = c;
      T[c].p = id;
    }
  }
  
  for(i = 0;i < n;++i){
    if(T[i].p == NIL){
      root = i;
    }
  }
  
  rec(root,0);
  
  for(i = 0;i < n;++i){
    print(i);
  }
  return 0;
}

