#include <stdio.h>

#define MAX 100000
#define NIL -1

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

node Tree[MAX];
int Depth[MAX];

//出力関数
void print(int u){
  int i, j;
  printf("node %d: parent = %d, depth = %d, ",u ,Tree[u].parent, Depth[u]);

  if(Tree[u].parent == NIL) printf("root, ");
  else if(Tree[u].left == NIL) printf("leaf, ");
  else printf("internal node, ");

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

//ノードの深さを求める関数
void calcDepth(int u, int p){
  Depth[u] = p;
  if(Tree[u].right != NIL) calcDepth(Tree[u].right, p);
  if(Tree[u].left != NIL) calcDepth(Tree[u].left, p+1);
}

int main(){
  int i, j, k, n;
  int id, sib, child;
  int root = NIL;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    Tree[i].parent = Tree[i].left = Tree[i].right = NIL;
  }

  for(i = 0; i < n; i++){
    scanf("%d %d",&id, &k);
    for(j = 0, sib = NIL; j < k; j++){
      scanf("%d", &child);
      Tree[child].parent = id;

      if(j == 0) Tree[id].left = child;
      else Tree[sib].right = child;
      sib = child;
    }
  }

  for(i = 0; i < n; i++){
    if(Tree[i].parent == -1) root = i;
  }

  calcDepth(root, 0);

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

