#include<stdio.h>

#define MAX 10000
#define NIL -1

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

struct node T[MAX];
int n;
int D[MAX];

int rec(int ,int );

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

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=NIL;
    T[i].left=NIL;
    T[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)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;
  }

  rec(r,0);

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

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

    if(T[i].parent==NIL)printf("root, ");
    else if(T[i].left==NIL)printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(j=0,c=T[i].left;c!=NIL;j++,c=T[c].right){
      if(j)printf(", ");
      printf("%d",c);
  }
    printf("]\n");
  }
  return 0;
}

int rec(int u,int p){
  D[u]=p;
  if(T[u].right!=NIL)rec(T[u].right,p);
  if(T[u].left!=NIL)rec(T[u].left,p+1);
  return 0;
}