#include<stdio.h>
#define MAX 100000
#define NIL -1
void depth(int,int);
void printz(int);
struct Node{int s,l,r;};
struct Node A[MAX];
int n,X[MAX];
int main(){
  int i,j,a,b,c,l,r;
  scanf("%d",&n);
for(i=0;i<n;i++){
    A[i].s=NIL;
  A[i].l = NIL;
  A[i].r =NIL;
}
  for(i=0;i<n;i++){
    scanf("%d",&a);
    scanf("%d",&b);
    for(j=0;j<b;j++){
      scanf("%d",&c);
      if(j==0)
	A[a].l=c;
      else
	A[l].r=c;
      l=c;
      A[c].s=a;
    }
  }
  for(i=0;i<n;i++){
    if(A[i].s==NIL) r=i;
  }
  depth(r,0);
  for(i=0;i<n;i++) printz(i);
  return 0;
}

void depth(int x,int y){
  X[x]=y;
  if(A[x].r!=NIL)
    depth(A[x].r,y);
  if(A[x].l!=NIL)
    depth(A[x].l,y+1);
}

void printz(int x){
int i,y,count=0;
  printf("node %d: ",x);
  printf("parent = %d, ",A[x].s);
  printf("depth = %d, ",X[x]);
  if(A[x].s==NIL)
    printf("root, ");
  else if(A[x].l==NIL)
    printf("leaf, ");
  else
    printf("internal node, ");
  printf("[");
  for(i=0,y=A[x].l;y!=NIL;i++,y=A[y].r){
    if(i)
      printf(",");
if(i==0)
  printf("%d",y);
    else
    printf(" %d",y);
  }
  printf("]\n");
}

