#include <stdio.h>
#define SIZE 100000
#define nil -1

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

node t[SIZE];
int n;
int dep[SIZE];

int depth(int,int);

int main(){
  int i,j,id,k,c,v;
  scanf("%d",&n);

  for(i=0; i<n; i++)
    t[i].par = t[i].right = t[i].left = nil;
  
  for(i=0; i<n; i++){
    scanf("%d %d",&id,&k);
    for(j=0; j<k; j++){
      int bef;
      scanf("%d",&c);
      if(j == 0) t[id].left = c;
      else t[bef].right = c;
      bef = c;
      t[c].par = id;
    }
  }

  for(i=0; i<n; i++)
    if(t[i].par == nil) v = i;

  depth(v,0);

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

    if(t[i].par == nil)printf("root, ");
    else if(t[i].left == nil) printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    
    int tmp;
    j = 0;
    tmp = t[i].left;
    while(tmp != nil){
      if(j != 0)printf(", ");
      printf("%d",tmp);
      j++;
      tmp = t[tmp].right;
    }
    printf("]\n");
  }
  
}

int depth(int u,int p){
  dep[u] = p;
  if(t[u].right != nil) depth(t[u].right,p);
  if(t[u].left != nil) depth(t[u].left,p+1);
}

