#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MAX_N 100000

struct Node{
  int key;
  struct Node *next;
  struct Node *prev;
};

typedef struct Node* NodePointer;
NodePointer nil[MAX_N];

int memo[MAX_N];
int getDepth(int,int*);
void init(int);
void insert(int,int);
void displayList(int,int);

int main(){
  int n,i,j,id,child,type;
  int parent[MAX_N],k[MAX_N],num[MAX_N];
  char name[3][14] = {"root","leaf","internal node"};

  memset(parent,-1,sizeof(parent));
  memset(memo,-1,sizeof(memo));
  memset(num,0,sizeof(num));

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&id,&k[i]); init(id);
    num[id] = k[i];
    for(j = 0 ; j < k[i] ; j++){
      scanf("%d",&child);
      parent[child] = id;
      insert(child,id);
    }
  }
  for(i = 0 ; i < n ; i++){
    printf("node %d: parent = %d, depth = %d, "
           ,i,parent[i],getDepth(i,parent));
    if(parent[i] == -1){ type = 0; }
    else if(num[i] == 0){ type = 1; }
    else{ type = 2; }
    printf("%s, [",name[type]);
    displayList(i,k[i]);
  }
  return 0;
}

int getDepth(int x,int *parent){
  if(parent[x] == -1){ return 0; }
  if(memo[x] >= 0){ return memo[x]; }
  return memo[x] = getDepth(parent[x],parent) + 1;
}

void init(int idx){
  nil[idx] = malloc(sizeof(struct Node));
  nil[idx]->next = nil[idx];
  nil[idx]->prev = nil[idx];
  nil[idx]->key = -1;
}

void insert(int key,int idx){
  NodePointer x,y;
  x = malloc(sizeof(struct Node));
  x->key = key;
   
  y = nil[idx]->next;
  nil[idx]->next = x;
  x->prev = nil[idx];
  x->next = y;
  y->prev = x;
}

void displayList(int idx,int len){
  NodePointer cur;
  int i = 0;
  for(cur = nil[idx]->prev ; cur != nil[idx] ; cur = cur->prev, i++){
    if(i > 0){ printf(", "); }
    printf("%d",cur->key);
  }
  printf("]\n");
}