#include<stdio.h>
#define MAX 100000
#define NO -1

void ans(int);
void depth(int,int);

  long int p[MAX];
  long int l[MAX];
  long int r[MAX];

int n,Dp[MAX];

int main(){

  int d,v,c,le,ri;
  int i,j;

  scanf("%d",&n);

  for(i = 0; i < n; i++) p[i] = l[i] = r[i] = NO;

  for(i = 0; i < n; i++){
    scanf("%d%d",&v,&d);

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

  for(i = 0; i < n; i++){
    if(p[i] == NO) ri = i;
  }

  depth(ri,0);

  for(i = 0; i < n; i++) ans(i);

  return 0;

}

void ans(int a){
  int i,b;
  printf("node %d: ",a);
  printf("parent = %d, ",p[a]);
  printf("depth = %d, ",Dp[a]);

  if(p[a] == NO) printf("root, ");
  else if(l[a] == NO) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i = 0, b = l[a]; b != NO; i++, b = r[b]){
    if(i != 0) printf(", ");
    printf("%d",b);
  }

  printf("]\n");
}

void depth(int a, int i){
  Dp[a] = i;
  if(r[a] != NO) depth(r[a],i);
  if(l[a] != NO) depth(l[a],i+1);
}