#include<stdio.h>
#define N 1000001
#define null -1

struct Node{
  int parent;
  int l;
  int r;
};

struct Node S[N];
int count=0;

int depth(int nodeid){
  if(S[nodeid].parent == null)
    return count;

  else{
    count++;
    return depth(S[nodeid].parent);
  }
}

void degree(int nodeid){
  if(nodeid != null){
    if(count != 0){
      printf(", ");
    }
    printf("%d", nodeid);
    count++;
    degree(S[nodeid].r);
  }
}

int main(void){
  int i, j, n, m, new, child, r, l;
  
  scanf("%d", &n);
  
  for(i=0; i<n; i++){
    S[i].parent = S[i].l = S[i].r = null;
  }
  
  for(i=0; i<n; i++){
    scanf("%d%d", &new, &m);
    for(j=0; j<m; j++){
      scanf("%d",&child);
      S[child].parent=new;
      if(j != 0){
	S[l].r=child;
      }
      else{
	S[new].l=child;
      }
      l=child;
    }
  }
  for(i=0; i<n; i++){
    count=0;
    printf("node %d: parent = %d, depth = %d, ", i, S[i].parent, depth(i));
    if(S[i].parent == null){
      printf("root, [");
      }
    else if(S[i].l == null){
      printf("leaf, [");
    }
    else {
      printf("internal node, [");
    }
    count=0;
    degree(S[i].l);
    printf("]\n");
  }
  return 0;
}