#include <stdio.h>
#define MAX 100005
#define NIL -1

struct Node {int p,l,r;};
struct Node T[MAX];
int n,H,D[MAX];

int Depth(int u){
  int d=0;

  for(;T[u].p != NIL;d++)u = T[u].p;
  return d;
}


int main(){
  int i,j,d,v,c,l,a,b;

  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].p = T[i].l = T[i].r = NIL;

  for(i=0;i<n;i++){
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j == 0)T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }

  H = 0;
  for(i=0;i<n;i++){
    D[i] = Depth(i);
    if(D[i] > H)H = D[i];
  }

  for(i=0;i<n;i++){/*print*/
    printf("node %d: ",i);
    printf("parent = %d, ",T[i].p);
    printf("depth = %d, ",D[i]);

    if(T[i].p == NIL)printf("root, ");
    else if(T[i].l == NIL)printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(a = 0,b = T[i].l;b != NIL;a++,b = T[b].r){
      if(a)printf(", ");
            printf("%d",b);
    }
    printf("]\n");
  }

  return 0;
}


