#include <stdio.h>
#include <stdlib.h>
//#define DEBUG
#define N 100000

typedef struct node{
  int id;
  int k;
  int parent;
  int depth;
  int *c;
}node;

void printTree(node*,int);
void quickSort(node*,int,int);
int partition(node*,int,int);
void parentDepth(node*,int);
int findRoot(node*,int);
void depth(node*,int,int);

int main(){
  node *tree;
  int i,j,n,root;

  scanf("%d",&n);

  tree = (node *)malloc(sizeof(node)*n);

  for(i=0;i<n;i++){
    scanf("%d %d",&tree[i].id,&tree[i].k);
    tree[i].c = (int *)malloc(tree[i].k*sizeof(int));
    for(j=0;j<tree[i].k;j++){
      scanf("%d",&tree[i].c[j]);
    }
  }

  quickSort(tree,0,n-1);
  root = findRoot(tree,n);
  tree[root].parent=-1;
  tree[root].depth=0;
  
  parentDepth(tree,n);
  depth(tree,root,0);

  #ifdef DEBUG
  printf("debug\n");
  for(i=0;i<n;i++){
    printf("id=%d k=%d parent=%d depth=%d ",tree[i].id,tree[i].k,tree[i].parent,tree[i].depth);
    for(j=0;j<tree[i].k;j++){
      printf("c%d=%d ",j+1,tree[i].c[j]);
    }
    printf("\n");
  }
  #endif

  printTree(tree,n);
    
  return 0;
}

void printTree(node* tree,int n){
  int i,j;
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,tree[i].parent,tree[i].depth);
    if(tree[i].depth == 0) printf("root, [");
    else if(tree[i].k == 0) printf("leaf, [");
    else printf("internal node, [");
    for(j=0;j<tree[i].k;j++){
      if(j != 0) printf(", ");
      printf("%d",tree[i].c[j]);
    }
    printf("]\n");
  }
  
  return;
}

void quickSort(node* tree,int p,int r){
  int q;
  if(p<r){
    q = partition(tree,p,r);
    quickSort(tree,p,q-1);
    quickSort(tree,q+1,r);
  }
  return;
}

int partition(node* tree,int p,int r){
  int x,i,j;
  node tmp;

  x=tree[r].id;

  i = p-1;
  for(j=p;j<r;j++){
    if(tree[j].id<=x){
      i = i+1;
      tmp=tree[i];
      tree[i]=tree[j];
      tree[j]=tmp;
    }
  }

  tmp=tree[i+1];
  tree[i+1]=tree[r];
  tree[r]=tmp;

  return i+1;
}

void parentDepth(node* tree,int n){
  int i,j;
  for(i=0;i<n;i++){
    for(j=0;j<tree[i].k;j++){
      tree[tree[i].c[j]].parent=i;
      //tree[tree[i].c[j]].depth=tree[i].depth+1;
    }
  }

  return;
}
  
int findRoot(node* tree,int n){
  int *a;
  int i,j;

  a=(int *)malloc(sizeof(int)*n);

  for(i=0;i<n;i++){
    a[i]=0;
  }

  for(i=0;i<n;i++){
    for(j=0;j<tree[i].k;j++){
      a[tree[i].c[j]]=1;
    }
  }

  for(i=0;i<n;i++){
    if(a[i]==0) return i;
  }

  return;
}

void depth(node* tree,int c,int d){
  int i;
  tree[c].depth=d;
  for(i=0;i<tree[c].k;i++){
    depth(tree,tree[c].c[i],d+1);
  }
  return;
}
  