#include <stdio.h>
#define max 100000
#define NIL -1

typedef struct{
  int parent;
  int left;
  int right;
}node;

node T[max];
int n,D[max];

void print(int);
void rec(int, int);

int main(){
  int i,j,k,d,v,c,l,r,id;
  scanf("%d",&n);
  
  
  for(i=0;i<n;i++){
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }
  for(i=0;i<n;i++){
   
    scanf("%d",&id);
    scanf("%d",&k);
    printf("\n%d %d %d  %d次数を入力",i,id,k,n);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      if(j==0){
	T[id].left = c;
      }
      else T[l].right = c;
      l = c;
      T[c].parent = id;
    }
  }
  printf("代入おわり\n");
  for(i = 0; i<n; i++){
    if(T[i].parent == NIL) r=i;
  }
  
  rec(r, 0);
  for(i=0;i<n;i++) print(i);
  
}

void print(int u){
  int i,c;
  printf("node %d: parent = %d, depth = %d, ",i,T[u].parent,D[i]);
  if(T[u].parent==NIL) printf("root, ");
  else if(T[u].left == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i=0, c = T[u].left ;;i++){
    if(c!=NIL){printf("%d",c);
      c = T[c].right;
    }
    if(c == NIL) break;
    printf(" ,");
  }
  printf("]\n");
}

void rec(int u,int p){
  D[u] = p;
  if(T[u].right != NIL) rec(T[u].right,p);
  if(T[u].left != NIL) rec(T[u].left,p+1);
}

