#include<stdio.h>
#include<stdlib.h>

typedef struct {
  int parent,leftchild,rightsibling;
} Node;

int main() {
  int i,j,n,id,k;
  int *child,*depth;
  Node *t;
  
  scanf("%d",&n);
  t = (Node*)malloc(sizeof(Node)*n);
  depth = (int*)malloc(sizeof(int)*n);
  for(i=0; i<n; i++){ 
    t[i].parent=t[i].leftchild=t[i].rightsibling=-1;
    depth[i]=0;
  }
  for(i=0; i<n; i++) {
    scanf("%d%d",&id,&k);
    if(k) {
      child = (int*)malloc(sizeof(int));
      for(j=0; j<k; j++) {
	scanf("%d",&child[j]);
	t[child[j]].parent = id;
	if(j==0) t[id].leftchild = child[j];
	else t[child[j-1]].rightsibling = child[j];
      }
      free(child);
    }
  }
  for(i=0; i<n; i++) {
    j=i;
    while(t[j].parent!=-1) {
      j=t[j].parent;
      depth[i]++;
    }
  }

  for(i=0; i<n; i++) {
    printf("node %d: parent = %d, depth = %d, ",i,t[i].parent,depth[i]);
    if(t[i].parent==-1) printf("root, [");
    else if(t[i].leftchild!=-1) printf("internal node, [");
    else printf("leaf, [");
    id=t[i].leftchild;
    j=0;
    while(id!=-1) {
      if(j) printf(", ");
      printf("%d",id);
      id = t[id].rightsibling;
      j++;
    }
    printf("]\n");
  }
  free(t);
  free(depth);

  return 0;
}