#include<stdio.h>
#define N 10000
#define NIL -1

struct Node{
  int p,
    l, 
    r;
};

struct Node T[N];
int a,f[N];

int getDepth(int b){
  int count = 0,i ;
  while(T[b].p!=NIL){
    b = T[b].p;
    count++;
  }
  return count;
}


void printChild(int u){
  int c;
  c = T[u].l;
  while(c != NIL){
    printf("%d, ",u);
    c = T[c].r;
  }
}


void print(int u){
  int i,c;
  printf("node %d: parent = %d, depth = %d, ",u,T[u].p,getDepth(u));
  if(T[u].p == NIL)printf("root, ");
  else if(T[u].l == NIL)printf("leaf, ");
  else printf("internal node, ");
  printf("[ ");
  for(i=0,c = T[u].l; c!=NIL;i++,c = T[c].r){ 
    if(i) printf(",");   
    printf("%d",c);
  }
  printf("]");
}




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

    for(j=0;j<d;j++){
      scanf("%d",&b);
      if(j==0)T[c].l = b;
      else T[k].r = b;
	k=b;
	T[b].p = c;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p == NIL) r = i;
  }
  for(i=0;i<a;i++){
    print(i);
    printf("\n");
  }
  return 0;
}