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

typedef struct {
  int parent;
  int left;
  int rsib;
} Node;

int depth[N];
Node node[N];

int depthcount(int x, int d){
  depth[x] = d;
  if(node[x].rsib != EMPTY)  depthcount(node[x].rsib,d);
  if(node[x].left != EMPTY)  depthcount(node[x].left,d+1);
}

int main(){
  int i,j,n,l,r,p,child,root,id,deg;

  scanf("%d",&n);
  for(i=0; i<n; i++) {
    node[i].left = EMPTY;
    node[i].rsib = EMPTY;
    node[i].parent = EMPTY;
  }


  for(i=0; i<n; i++){
    scanf("%d%d",&id,&deg);
    for(j=0; j<deg; j++){
      scanf("%d",&child);
      if(j == 0) {
	node[id].left = child;
	l = child;
      }
      else {
	node[l].rsib = child;
      }
      l = child;
      node[child].parent = id;
    }
  }
  for(i=0; i<n; i++) if(node[i].parent == EMPTY) root = i;
  depthcount(root,0);  //根と深さの数がはいる

    for(i=0; i<n; i++){
      printf("node %d: paretnt = %d, depth = %d, ",i,node[i].parent,depth[i]);
      if(node[i].parent == EMPTY) printf("root, ");
      else if(node[i].left == EMPTY) printf("leaf, ");
      else printf("internal node, ");
    
      printf("[");
      for(j=0, child=node[i].left; child != EMPTY; j++, child = node[child].rsib){
	if(j != 0) printf(", ");
	 printf("%d",child);
      }
      printf("]\n");
    }

  return 0;
}