#include<stdio.h>
#include<stdlib.h>

struct tree{
  int id;
  int p;
  int d;
  char *type;
  int *c;
  int k;
};

int pcheck(struct tree *T,int n, int id){
  int i, j;
  for(i=0; i<n; i++){
    for(j=0; j<T[i].k; j++){
      if(id == T[i].c[j]){
        return T[i].id;
      }
    }
  }
  return -1;
}

int depth(struct tree *T, int d){
  if(T[d].p == -1){
  return 0;
  }
  else{
    return depth(T, T[d].p)+1;
  }
}

int main(){

  int n, i, k, j,cnt, root;
  struct tree *u, a;

  scanf("%d",&n);
  u = (struct tree *)malloc(sizeof(struct tree) * n);
  for(i=0; i<n; i++){
    scanf("%d%d", &u[i].id, &k);
    u[i].c = (int *)malloc(sizeof(int) * k);
    u[i].k = k;
    u[i].d = 0;
    u[i].c[0] = -1;
    for(j=0; j<k; j++){
      scanf("%d", &u[i].c[j]);
    }
  }

  for(i=0; i<n; i++){
    cnt=0;

    u[i].p = pcheck(u, n, u[i].id);
    /*for(j=0; j<u[i].k; j++){
      u[u[i].c[j]].d = u[i].d + 1;
      cnt=1;
      }*/
    if(u[i].p == -1){
      u[i].type = "root";
      continue;
    }
    else if(u[i].k!=0){
      u[i].type = "internal node";
      continue;
    }
    else{
      u[i].type = "leaf";
    }
  }

  for(i=0; i<n; i++){
    cnt = 0;
    for(j=i+1; j<n; j++){
      if(u[i].id>u[j].id){
        a = u[i];
        u[i] = u[j];
        u[j] = a;
      }
    }
  }
  for(i=0; i<n; i++){
    u[i].d = depth(u, u[i].id);
    printf("node %d: parent = %d, depth = %d, %s, [", u[i].id, u[i].p, u[i].d, u[i].type);
    for(j=0; j<u[i].k-1; j++){
      printf("%d, ", u[i].c[j]);
    }
    if(u[i].c[j]!=-1){
    printf("%d]\n", u[i].c[j]);
    }
    else{
      printf("]\n");
    }
  }

  return 0;
}
