#include <stdio.h>
#define N 100001

int getDepth(int);

typedef struct Node {
  int parent;
  int left;
  int right;
} Node;
  Node T[N];
int depth[N];

int main()
  {
    int i,j,u,n,deg,id,k,sibling ,left,x,right;

    scanf("%d",&n);
    for(i = 0; i < n; i++) {
      T[i].parent = -1;
      T[i].left = -1;
      T[i].right = -1;
    }

    for(i = 0; i < n; i++) {
      scanf("%d %d",&id,&k);

      if (k != 0){
      scanf("%d",&sibling);
      T[sibling].parent = id;
      T[id].left = sibling;
      right = sibling;

      for(j = 1; j < k ; j++) {
        scanf("%d",&sibling);
        T[sibling].parent = id;
        T[right].right = sibling;
        right = sibling;
      }
    }
    }
    for(u = 0; u < n; u++) {
      depth[u] = getDepth(u);
    }

    for(i = 0; i < n; i++) {
      printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,depth[i]);

      if(T[i].parent == -1) printf("root, [");
      else if(T[i].left == -1) printf("leaf,[");
      else printf("internal node, [");

      x = T[i].left;
      if(x != -1) {
        while(1) {
          if(T[x].right == -1) {
            printf("%d",x);
            break;
          }
          else {
            printf("%d, ",x);
            x = T[x].right;
          }
        }
      }
      printf("]\n");
    }

    return 0;
  }
  
int getDepth(int u) {
  int  depth = 0;
  while(T[u].parent >= 0) {
    u = T[u].parent;
    depth++;
  }
  return depth;
}