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

int parent[MAX],left[MAX],right[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  printf("node %d:",u);
  printf("parent = %d,",parent[u]);
  printf("depth = %d,",D[u]);
  if(parent[u]==NIL) printf("root, ");
  else if (left[u]==NIL)printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i=0,c=left[u];c!=NIL; i++, c=right[c]){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}
  void rec(int u,int p){
    D[u]=p;
    if(right[u]!=NIL){  rec(right[u],p);}
    if(left[u]!=NIL) {  rec(left[u],p+1);}
  }

  int main(){
    int i,j,d,v,c,l,r;
    scanf("%d",&n);
    for (i=0;i<n;i++) {
      parent[i]=left[i]=right[i]=NIL;
    }
    for (i=0;i<n;i++){
      scanf("%d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)left[v]=c;
      else right[l]=c;
      l=c;
      parent[c]=v;
    }
  }
  for (i=0;i<n;i++){
    if (parent[i]==NIL)r=i;
  }
  rec(r,0);

  for (i=0;i<n;i++) print(i);
  return 0;
}

