#include <stdio.h>
#define MAX 100000

int Depth(int);

struct node
{
  int p;
  int r;
  int l;
} typedef node;

node N[MAX];

int main()
{
    int i, j;
    int n, id, k, nid;

    scanf("%d", &n);
    
    for(i = 0; i < n; i++)
    {
        N[i].p = -1;
        N[i].r = -1;
        N[i].l = -1;
    }
    
    for(i = 0; i < n; i++)
    {
        scanf("%d %d", &id, &k);

        if(k > 0)
	    {
	        scanf("%d", &N[id].l);
	        N[N[id].l].p = id;
	        nid = N[id].l;
	    }
        for(j = 1; j < k; j++)
	    {
	        scanf("%d", &N[nid].r);
	        N[N[nid].r].p = id;
	        nid = N[nid].r;
	    }
    }
    
    for(i = 0; i < n; i++)
    {
        printf("node %d: ", i);

        printf("parent = %d, ", N[i].p);
 
        printf("depth = %d, ", Depth(i));

        if(N[i].p == -1) printf("root, ");
        else if(N[i].l == -1) printf("leaf, ");
        else printf("internal node, ");

        printf("[");
        if(N[i].l != -1)
	    {
	        printf("%d", N[i].l);
	        nid = N[i].l;
	    }
        while(N[nid].r != -1)
	    {
	    printf(", %d", N[nid].r);
	    nid = N[nid].r;
	    }
	    printf("]\n");
    }
    return 0;
}

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

    while(N[id].p != -1)
    {
        count++;
        id = N[id].p;
    }
    return count;
}