#include<stdio.h>
#define N 100005
#define NIL -1

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

struct node Tree[N];
int n,D[N];

void print(int);
int rec(int,int);

int main()
{
  int i,j,n,id,k,c,l,r;
  scanf("%d",&n);

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

  rec(r,0);
  for(i=0;i<n;i++) print(i);
  return 0;
}

void print(int u)
{
  int i,c;
  printf("node %d: parent = %d, ",u,Tree[u].parent);
  printf("depth = %d, ",D[u]);

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

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

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

