#include<stdio.h>

#define NIL -1

typedef struct{
  int parent,left,right;
}node;

void getdepth(int,int);
void printchildren(int);

node T[100000];
int D[100000];

int main(){
  int i,j,d,v,c,l,r,n;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent = T[i].left = T[i].right = D[i] = NIL;
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j == 0)T[v].left = c;
      else T[l].right = c;
      l = c;
      T[c].parent = v;
    }
  }

  for(i=0;i<n;i++){
    if(T[i].parent == NIL)r = i;
  }
  
  getdepth(r,0);

  for(i=0;i<n;i++)printchildren(i);

  return 0;
}

void getdepth(int u,int p){
  D[u] = p;
  if(T[u].right != NIL)getdepth(T[u].right,p);
  if(T[u].left != NIL)getdepth(T[u].left,p);
}

void printchildren(int u){
  int i;
  int c = T[u].left;

  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("depth = %d, ",D[u]);

  if(T[u].parent == NIL)printf("root, ");
  else if(T[u].left == NIL)printf("leaf, ");
  else printf("internal node, ");
  
  printf("[");
  for(i = 0,c = T[u].left ;c != NIL ;i++){
    if(i)printf(", ");
    printf("%d",c);
    c = T[c].right;
  }
  printf("]\n");
  
}