#include<stdio.h>
#define MAX 100000

int main(){
  int n,i,j;
  scanf("%d",&n);
  int node[n],parent[n],numchild[n],depth[n],child[n][20];
  for( i = 0 ; i  < n ; i++ )
    {
      parent[i] = -1;
      depth[i] = 0;
      scanf("%d%d",&node[i],&numchild[i]);
      for( j =  0 ; j < numchild[i] ; j++ ) scanf("%d",&child[i][j]);
    }

  for( i = 0 ; i < n ; i++ )
    {
      for( j = 0 ; j < numchild[i] ; j++ ) parent[child[i][j]] = i;   
    }
  int x;
  for( i = 0 ; i < n ; i++ )
    {
      x = i;
       while(1){
	if( parent[x] != -1 )
	  {
	    x = parent[x];
	    depth[i]++;
	  }
	else break;
       }
      printf("node %d: parent = %d, depth = %d, ",i,parent[i],depth[i]);

      if( numchild[i] == 0 ) printf("leaf, []\n");

      else
	{
	  if( parent[i] == -1 ){
	    printf("root, [");
	    for( j = 0 ; j < numchild[i]-1 ; j++ ) printf("%d, ",child[i][j]);
	    printf("%d]\n",child[i][j]);
	  }
	  else{
	    printf("internal node, [");
	    for( j = 0 ; j < numchild[i]-1 ; j++ ) printf("%d, ",child[i][j]);
	    printf("%d]\n",child[i][j]);
	  }

	}

    }

  return 0;
}