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


struct Node{
  int p,l,r;
};
  
struct Node tree[MAX];
int n,dep[MAX];

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

int main(){
  int i,j,de,val,c,le,ro;

  scanf("%d",&n);
  for(i=0;i<n;i++) tree[i].p = tree[i].l = tree[i].r = NIL;

  for(i=0;i<n;i++){
    scanf("%d%d",&val,&de);
    for(j=0;j<de;j++){
      scanf("%d",&c);
      if(j==0) tree[val].l = c;
      else tree[le].r = c;
      le=c;
      tree[c].p = val;
    }
  }
  for(i=0;i<n;i++){
    if(tree[i].p == NIL) ro=i;
  }

  rec(ro,0);

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

  return 0;
}

void print(int u){
  int i,c;
  printf("node %d: parent = %d, depth = %d,",u,tree[u].p,dep[u]);
  if(tree[u].p == NIL) printf(" root, ");
  else if(tree[u].l == NIL) printf(" leaf, ");
  else printf(" internal node, ");

  printf("[");

  for(i=0,c=tree[u].l; c != NIL; i++, c=tree[c].r){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int rec(int u,int p){
  dep[u] = p;
  if(tree[u].r != NIL) rec(tree[u].r,p);
  if(tree[u].l != NIL) rec(tree[u].l,p+1);
}

