#include <stdio.h>
#define MAX 100000

int Depth(int);

struct Node
{
  int parent;
  int left;
  int right;
};

struct Node T[MAX];

int main()
{
  int n,i,j,k,p,d,t;
  int child,id,lc;
  //int Type["root","internal node","leaf"];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    {
      T[i].parent = -1;
      T[i].left = -1;
      T[i].right = -1;
    }
  
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&id,&k);
      for(j=0;j<k;j++)
	{
	  scanf("%d",&child);
	  lc = T[child].left;
	  if(j==0) T[j].left=child;
	  T[lc].right=child;
	}
    }
 

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

      d = Depth(i);
      
      printf("node %d: parent = %d, depth = %d, , [",i,T[i].parent,d);
      
      for(j=0;j<n;j++)
	{
	  if(i==T[t].parent) printf("%d",i);
	}
      printf("]\n");
    }

  return 0;
}


int Depth(int i)
{
  int count=0;

  while(1)
    {
      if(T[i].parent == -1) break;
      else i = T[i].parent;
      count++;
    }
  return count;
}
  