#include <stdio.h>
#include <string.h>
#define N 100000

int depth(int);
void pchild(int);

typedef struct{
  int parent;
  int left;
  int right;
} data;
data node[N];


int main(){
  int n,i,j,c,t,l,x,d[20];
  char typ[N][20],a[] = "root",b[] = "leaf",e[] = "internal node";

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    node[i].parent = node[i].left = node[i].right = -1;
  }
  for(i = 0;i < n;i++){
    scanf("%d%d",&x,&c);
    for(j = 0;j < c;j++){
      if(j == 0){
	scanf("%d",&node[x].left);
      node[node[x].left].parent = x;
      l = node[x].left;
      }
      else {scanf("%d",&node[l].right);
      node[node[l].right].parent = x;
      l = node[l].right;
      }
    }
  }
  for(i = 0;i < n;i++){

    if(node[i].parent == -1) strcpy(typ[i], a);
    else if(node[i].left == -1) strcpy(typ[i], b);
    else strcpy(typ[i], e);
    
    d[i] = depth(i);
    printf("node %d: parent = %d, depth = %d, %s, [",i,node[i].parent,d[i],typ[i]);
    pchild(i);
  printf("]\n");
  }
  return 0;
}

int depth(int u){
  int d=0;
  while(node[u].parent != -1){
    u = node[u].parent;
    d++;
  }
  return d;
}

void pchild(int u){
  int c = node[u].left,i=0;
  while(c != -1){
    if(i != 0) printf(", ");
    printf("%d",c);
    c = node[c].right;
    i++;
  }
}

