#include<stdio.h>

#define MAX 100005
#define NIL -1

struct Node{
  int w,l,r;
};

struct Node X[MAX];
int a,A[MAX];

void print(int s){
  int i,b;
  printf("node %d: ",s);
  printf("parent = %d, ",X[s].w);
  printf("depth = %d, ",A[s]);

  if(X[s].w == NIL)
    printf("root, ");
  else if(X[s].l==NIL)
    printf("leaf, ");
  else
    printf("internal node, ");

  printf("[");

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


void rec(int s,int w){
  A[s] = w;
  if(X[s].r!=NIL) rec(X[s].r,w);
  if(X[s].l!=NIL) rec(X[s].l,w+1);
}

int main(){
  int i,j,l,r,b,v,c;
  scanf("%d",&a);
  for(i = 0;i<a;i++)
    X[i].w = X[i].l = X[i].r = NIL;

  for(i = 0;i<a;i++){
    scanf("%d%d",&v,&c);
    for(j = 0;j<c;j++){
      scanf("%d",&b);
      if(j==0)X[v].l = b;
      else X[l].r = b;
      l = b;
      X[b].w = v;
    }
  }
  for(i = 0;i<a;i++){
    if(X[i].w == NIL)r =i;
  }

  rec(r,0);

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

  return 0;
}

