#include <stdio.h>
#define N 100001

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

void getDepth(int,int);

int depth[N];
Node T[N];

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

    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(i = 0; i < n; i++){
      if(T[i].parent == -1) r = i;
    }

    getDepth(r,0);

    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;
  }
  
void getDepth(int n ,int p) {
  depth[n]=p;

  if(T[n].right != -1) getDepth(T[n].right,p);
  if(T[n].left != -1) getDepth(T[n].left, p+1);
  return;
}
 