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

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

int getDepth(int);
void Print(int);

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

  for(i = 0; i < n; i++){
    scanf("%d %d",&v, &k);
    for(j = 0; j < k; 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++){
      A[i] = getDepth(i);
      if(A[i] > H) H = A[i];
    }
    for(i = 0; i < n; i++) Print(i);
    return 0;
  }

int getDepth(int u){
  int k = 0;
  for(;T[u].p != NOT;k++){
    u = T[u].p;
  }
  return k;
}

void Print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",A[u]);

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

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

