//Rooted Trees

#include<stdio.h>
#define N 100005
#define NILL -1

struct Node{
  int a,b,c;
};

struct Node tree[N];
int n, dep[N];

void print(int u)
{
  int i,imp;
  printf("node %d: ",u);
  printf("parent = %d, ",tree[u].a);
  printf("depth = %d, ",dep[u]);

  if(tree[u].a == NILL)
    {
      printf("root, ");
    }else if(tree[u].b == NILL)
    {
      printf("leaf, ");
    }else printf("internal node, ");

  printf("[");
  for(i = 0,imp = tree[u].b; imp != NILL; i++, imp = tree[imp].c)
    {
      if(i == 0) printf("%d",imp);
      else printf(", %d",imp);
    }
  printf("]\n");
}

int work(int u, int a)
{
  dep[u] = a;
  if(tree[u].c != NILL) work(tree[u].c,a);
  if(tree[u].b != NILL) work(tree[u].b,a+1);
}

int main()
{
  int i,j,b,c,imp,k,x,rt;
  scanf("%d",&n);

  for(i = 0; i < n; i++)
    {
      tree[i].a = tree[i].b = tree[i].c = NILL;
    }

  for(i = 0; i < n; i++)
    {
      scanf("%d %d",&x,&k);
      for(j = 0; j < k; j++)
	{
	  scanf("%d",&imp);
	  if(j == 0) tree[x].b = imp;
	  else tree[b].c = imp;
	  b = imp;
	  tree[imp].a = x;
	}
    }

  for(i = 0; i < n; i++)
    {
      if(tree[i].a == NILL) c = i;
    }

  work(c,0);

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

