#include<stdio.h>
#define MAX 100000
#define NIL -1
 
typedef struct{
  int parent, left, right, depth;
} Node;
 
int set_depth(Node *tree, int id, int depth){
  tree[id].depth = depth;
  if(tree[id].right != NIL)
    set_depth(tree, tree[id].right, depth);
  if(tree[id].left != NIL)
    set_depth(tree, tree[id].left, depth+1);
  return 0;
}
 
int main(void){
  Node tree[MAX];
  int i, j, n, id, k, c, prev;
  char *kind[3] = {"root", "leaf", "internal node"};
 
  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; j<k; ++j){
      scanf("%d", &c);
      tree[c].parent = id;
      if(j==0)
        tree[id].left = c;
      else
        tree[prev].right = c;
      prev = c;
    }
  }
 
  for(id=0; tree[id].parent!=NIL; id=tree[id].parent){}
  set_depth(tree, id, 0);
 
  for(i=0; i<n; ++i){
    printf("node %d: parent = %d, depth = %d, ", i, tree[i].parent, tree[i].depth);
    if(tree[i].parent == NIL)
      printf("%s, [", kind[0]);
    else if(tree[i].left == NIL){
      printf("%s, []\n", kind[1]);
      continue;
    }else
      printf("%s, [", kind[2]);
    id = tree[i].left;
    if(id != NIL)
      printf("%d", id);
    for(id=tree[id].right; id != NIL; id=tree[id].right)
      printf(", %d", id);
    printf("]\n");
  }
 
  return 0;
}