/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on July 6, 2018, 12:00 PM
 */

#include <stdio.h>
#include <stdlib.h>
#define MAX 100005
#define NIL -1

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

Node Tree[MAX];
int num, H, Depth[MAX];

int getDepth(int u);
void print(int u);

int main(int argc, char** argv) {
    int index, depth, child, l, size;
    scanf("%d", &size);

    //Initialize binary tree
    for (int i = 0; i < size; i++ ) Tree[i].parent = Tree[i].left = Tree[i].right = NIL;

    for (int ix = 0; ix < size; ix++ )
    {
        scanf("%d %d", &index, &depth);
        for (int j = 0; j < depth; j++ )
        {
            scanf("%d", &child);
            if ( j == 0 ) Tree[index].left = child;
            else Tree[l].right = child;
            l = child;
            Tree[child].parent = index;
        }
    }

    H = 0;
    for (int i = 0; i < size; i++ )
    {
        Depth[i] = getDepth(i);
        if ( Depth[i] > H ) H = Depth[i];
    }

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

int getDepth(int u)
{
    int i = 0;
    for(; Tree[u].parent != NIL ; i++) u = Tree[u].parent;
    return i;
}

void print(int u)
{
    int c;
    printf("node %d: ", u);
    printf("parent = %d, ", Tree[u].parent);
    printf("depth = %d, ", Depth[u]);

    if ( Tree[u].parent == NIL ) printf("root, ");
    else if ( Tree[u].left == NIL ) printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(int i = 0, c = Tree[u].left; c != NIL; i++, c = Tree[c].right)
    {
        if (i) printf(", ");
        printf("%d", c);
    }
    printf("]\n");
}



