import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;
import std.math;
import std.random;
import std.range;
import std.functional;
import std.container;

class t
{
    sizediff_t left, right, parent;
    int depth;
    this()
    {
        parent = left = right = -1;
    }
}
void rrr(t[] tt, t a, int d)
{
    a.depth = d;
    if (a.right != -1)
    {
        rrr(tt, tt[a.right], d);
    }
    if (a.left != -1)
    {
        rrr(tt, tt[a.left], d + 1);
    }
}
void main()
{
    auto c = readln.strip.to!int;
    auto tt = new t[c];
    foreach (i; 0..c)
        tt[i] = new t();
    size_t l = 0;
    foreach (i; 0..c)
    {
        auto a = readln().strip.split(" ").map!(to!int).array;
        foreach (k, j; a[2..$])
        {
            if (k == 0)
            {
                tt[a[0]].left = j;
            }
            else
            {
                tt[l].right = j;
            }
            l = j;
            tt[j].parent = a[0];
        }
    }
    foreach (i; 0..c)
    {
        if (tt[i].parent ==  -1)
        {
            rrr(tt, tt[i], 0);
        }
    }
    foreach (i, t; tt)
    {
        writef("node %d: parent = %d, depth = %d, ", i, t.parent, t.depth);
        if (t.parent == -1)
        {
            write("root");
        }
        else if (t.left == -1)
        {
            write("leaf");
        }
        else
        {
            write("internal node");
        }
        bool f = false;
        write(", [");
        auto j = t.left;
        while (j != -1)
        {
            writef("%d", j);
            j = tt[j].right;
            if (j != -1)
            {
                write(", ");
            }
        }
        write("]");
        writeln();
    }
}

