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

typedef struct Node{
  int parent;
  int leaf;
  int root;
} Node;

Node T[M];
Node d[M];
int n;

int depth(int);
void print(int); 
int main(){
  int i;
  int j;
  int n;
  int id;
  int k;
  int c;
  int m;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent = NIL;
    T[i].leaf = NIL;
    T[i].root = NIL;
  }

  for(i=0;i<n;i++){
    scanf(" %d %d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      T[c].parent = id;
      if(j == 0) T[id].leaf = c;
      else T[m].root = c;
      m = c;
    }
  }

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,depth(i));
    if(T[i].parent == NIL) printf("root, [");
    else if(T[i].leaf == NIL) printf("leaf, [");
    else printf("internal node, [");
    print(T[i].leaf);
    printf("]\n");
  }
  return 0;
}

int depth(int x){
  int y;
  if(T[x].parent == NIL) return 0;
  else{
    y = depth(T[x].parent) + 1;
    return y;
  }
}

void print(int x){
  if(x == NIL) return;
  else{
    if(T[x].root == NIL) printf("%d",x);
    else{
      printf("%d, ",x);
      print(T[x].root);
    }
  }
}

