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
{
    int parent, left, right;
    this()
    {
        parent = left = right = -1;
    }

    int depth;
    int height;
}
void dep(t[] tt, int i, int d = 0)
{
    if (i == -1)
    {
        return;
    }
    tt[i].depth = d;
    dep(tt, tt[i].left, d + 1);
    dep(tt, tt[i].right, d + 1);
}
int hei(t[] tt, int i)
{
    auto a1 = 0, a2 = 0;
    if (tt[i].left != -1)
        a1 = hei(tt, tt[i].left) + 1;
    if (tt[i].right != -1)
        a2 = hei(tt, tt[i].right) + 1;
    tt[i].height = max(a1, a2);
    return tt[i].height;
}
void main()
{
    auto c = readln.strip.to!int;
    auto tt = new t[c];
    foreach (i; 0..c)
        tt[i] = new t();
    foreach (i; 0..c)
    {
        auto a = readln().strip.split(" ").map!(to!int).array;
        if (a[1] != -1)
        {
            tt[a[0]].left = a[1];
            tt[a[1]].parent = a[0];
        }
        if (a[2] != -1)
        {
            tt[a[0]].right = a[2];
            tt[a[2]].parent = a[0];
        }
    }
    foreach (i; 0..c)
    {
        if (tt[i].parent == -1)
        {
            dep(tt, i);
            hei(tt, i);
        }
    }
    foreach (i; 0..c)
    {
        int s = -1;
        if (tt[i].parent != -1)
        {
            if (tt[tt[i].parent].left == i)
            {
                s = tt[tt[i].parent].right;
            }
            else
            {
                s = tt[tt[i].parent].left;
            }
        }
        writef("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, tt[i].parent, s, (tt[i].left != -1 ? 1 : 0) + (tt[i].right != -1 ? 1 : 0), tt[i].depth, tt[i].height);
        if (tt[i].parent == -1)
        {
            writef("root");
        }
        else if (tt[i].left == -1 && tt[i].right == -1)
        {
            writef("leaf");
        }
        else
        {
            writef("internal node");
        }
        writeln();
    }
}

