#include<stdio.h>
#define N 100001
int depth(int);
struct Node{
  int p;
  int l;
  int r;
};
struct Node T[N];


int main()
{

  int i,j,n,par,child,sib,k,x;

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

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

  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ",i , T[i].p,depth(i));
    if(T[i].l  == -1 && T[i].p != -1)printf("leaf, ");
    else if(T[i].p == -1)printf("root, ");
    else if(T[i].l != -1)printf("internal node, ");
    printf("[");

    if(T[i].l != -1){
      printf("%d",T[i].l);

      sib = T[i].l;

      while(1){
	if(T[sib].r == -1)break;
	printf(", %d",T[sib].r);
      sib = T[sib].r;
    }
    }
  printf("]\n");
  }

  return 0;
}

int depth(int k){
  int dep =0;
  for(dep = 0; T[k].p != -1; dep++){
    k = T[k].p;
  }
    return dep;
  }