#include<stdio.h>
#define MAX 1000001
#define NIL NULL

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

Node T[MAX];
int count=0,ids[MAX];
int i,y,j;

int main(){
  int n,id,m,l;
  int depth(int);
  void internal();

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent = NIL;
    T[i].left = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&id,&m);
    ids[id] = m;
    for(j=0;j<m;j++){
      scanf("%d",&l);
      T[l].parent = id;
      if(j == 0)  T[id].left = l;
      else if(j > 0) T[y].right = l;
      y = l;
    }
  }
  
  for(i=0;i<n;i++){
    count = 0;
    printf("node %d: parent = 5d, depth = %d, ",i,T[i].parent,depth(i));
    if(T[i].parent == NIL){
      printf("root, [");
      internal();
      printf("]\n");
    }
    else if(T[i].left == NIL) printf("leaf, []\n");
  }
  return 0;
}

int depth(int x){
  int p;
  p = T[x].parent;
  if(p == NIL) return count;
  count++;
  depth(p);
}

void internal(){
  for(j=0;j<ids[i];j++){
    if(j == 0){
      printf("%d",T[i].left);
      y = T[i].left;
    }
    else if(j < ids[i] - 1){
      printf(", %d",T[y].right);
      y = T[y].right;
    }
    else if(j <= ids[i] - 1)printf(", %d",T[y].left);
  }
}

    
