#include <stdio.h>
#define N 100005
#define NIL -1
struct Node{
  int parent;
  int left;
  int right;
};
struct Node A[N];
int n,B[N];
void print(int j){
  int i,c;
  printf("node %d: ",j);
  printf("parent = %d, ",A[j].parent);
  printf("depth = %d, ",B[j]);
  if(A[j].parent==NIL)printf("root, ");
  else if(A[j].left==NIL)printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i=0,c=A[j].left;c!=NIL;i++,c=A[c].right){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}
int rec(int z,int p){
  B[z]=p;
  if(A[z].right!=NIL)rec(A[z].right,p);
  if(A[z].left!=NIL)rec(A[z].left,p+1);
}

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

