#include<stdio.h>
#define Max 100005
#define None -1
typedef struct {
  int parent,left,right;
}Node;
Node Tree[Max];
int n,Depth[Max];
void print_out(int);
int dep(int ,int);
int main(){
  int i,j,d,v,c,r;
  int l=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    Tree[i].parent=None;
    Tree[i].left=None;
    Tree[i].right=None;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)Tree[v].left=c;
      else Tree[l].right=c;
      l=c;
      Tree[c].parent=v;
    }
  }
  for(i=0;i<n;i++){
    if(Tree[i].parent==None)r=i;
  }
  dep(r,0);
  for(i=0;i<n;i++)print_out(i);
  return 0;
}

int dep(int u,int p){
  Depth[u]=p;
  if(Tree[u].right!=None)dep(Tree[u].right,p);
  if(Tree[u].left!=None)dep(Tree[u].left,p+1);
}
void print_out(int u){
  int i,c;
  printf("node %d:",u);
  printf("parent = %d,",Tree[u].parent);
  printf("depth = %d,",Depth[u]);
  if(Tree[u].parent == None)printf("root, ");
  else if(Tree[u].left == None)printf("leaf, ");
  else printf("internal node");
  printf("[");
  for(i = 0,c=Tree[u].left;c!=None;i++,c=Tree[c].right){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}