#include<stdio.h>
#define MAX 10005

typedef struct node{
  int x,y,z;
}Node;

Node T[MAX];
int n,D[MAX];

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

int main(){
  int i,j,a,b,c,y,z;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].x=T[i].y=T[i].z=-1;

  for(i=0;i<n;i++){
    scanf("%d%d",&b,&a);
    for(j=0;j<a;j++){
      scanf("%d",&c);
      if(j==0)
	T[a].y=c;
      else T[y].z=c;
      y=c;
      T[c].x=b;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].x==-1)y=i;
  }
  rec(z,0);

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

void print(int u){
  int i,c;

  printf("node %d: ",u);
  printf("parent = %d, ",T[u].x);
  printf("depth = %d, ",D[u]);

  if(T[u].x==-1) printf("root, ");
  else if (T[u].y==-1) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].y; c!=-1; i++, c=T[c].z){
    if(i) printf(", ");
    printf("%d",c);

  }
  printf("]\n");
}

int rec(int u, int x){
  D[u] = x;
  if(T[u].z !=-1) rec(T[u].z, x);
  if(T[u].y !=-1) rec(T[u].y, x+1);
}