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

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

Node T[MAX];
int n, D[MAX];

void setDepth(int u, int d){
  D[u] = d;
  if(T[u].right != NIL)setDepth(T[u].right,d);
  if(T[u].left != NIL)setDepth(T[u].left,d+1);
}

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("depth = %d, ",D[u]);

  if(T[u].parent == NIL){
    printf("root, ");
  } else if (T[u].left == NIL){
    printf("leaf, ");
  } else {
    printf("internal node, ");
  }
  printf("[");
  for(i=0,c=T[u].left;c!=NIL;i++,c=T[c].right){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int main(){
  int i,j,id,k, l, r, root = 0;
  scanf("%d",&n);

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

  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&r);
      if(j==0)T[id].left = r;
      else T[l].right = r;
      l = r;
      T[r].parent = id;
    }
  }

  for(i=0;i<n;i++) if(T[i].parent==NIL)root = i;

  setDepth(root,0);

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

  return 0;
}

