#include <stdio.h>

#define MAX 100004
#define nil -1

void rec(int, int);
void print(int);

typedef struct{
  int p;
  int left;
  int right;
}node;

node Node[MAX];
int Depth[MAX];

int main(){
  int n, a, b, id, k, node, root, left;

  scanf("%d",&n);
  for(a = 0; a < n; a++){
    Node[a].p = Node[a].left = Node[a].right = nil;
  }

  for(a = 0; a < n; a++){
    scanf("%d%d",&id,&k);
    for(b = 0; b < k; b++){
      scanf("%d",&node);
      if(b == 0) Node[id].left = node;
      else Node[left].right = node;
      left = node;
      Node[node].p = id;
    }
  }

  for(a = 0; a < n; a++){
    if(Node[a].p == nil) root = a;
  }

  rec(root,0);

  for(a = 0; a < n; a++){
    print(a);
  }

  return 0;
}

void rec(int node, int p){
  Depth[node] = p;
  if(Node[node].right != nil) rec(Node[node].right,p);
  if(Node[node].left != nil) rec(Node[node].left,p+1);
}

void print(int node){
  int a, left;
  printf("node %d: parent = %d, ",node,Node[node].p);
  printf("depth = %d, ",Depth[node]);

  if(Node[node].p == nil) printf("root, ");
  else if(Node[node].left == nil) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  left = Node[node].left;
  for(a = 0; left != nil; a++){
    if(a != 0) printf(", ");
    printf("%d",left);
    left = Node[left].right;
  }
  printf("]\n");
}

