function main(_stdin) {
    const stdin = _stdin.trim().split('\n');
    const n = Number(stdin.shift());
    const T = [];
    for (let i = 0; i < n; i++) {
        T.push({ parent: null, left: null, right: null });
    }
    for (let line of stdin) {
        const [id, left, right] = line.split(' ').map(Number);
        if(left > -1) {
            T[left].parent = id;
        }
        if(right > -1) {
            T[right].parent = id;
        }
        T[id].left = left;
        T[id].right = right;
    }


    for (let i = 0, l = T.length; i < l; i++) {
        const sibling = getSib(i, T);
        const degree = T[i].left > -1 && T[i].right > -1 ? 2 : T[i].left < 0 && T[i].right < 0 ? 0 : 1;
        const depth = getDepth(i, T);
        const height = getHeight(i, T);
        const type = T[i].parent === null ? 'root' : T[i].left < 0 && T[i].right < 0 ? 'leaf' : 'internal node';

        console.log(`node ${i}: parent = ${T[i].parent === null ? -1 : T[i].parent}, sibling = ${sibling}, degree = ${degree}, depth = ${depth}, height = ${height}, ${type}`);
    }
}

function getSib(id, T) {
    if (T[id].parent === null) return -1;
    const pid = T[id].parent;
    return T[pid].left === id ? T[pid].right : T[pid].left;
}

function getDepth(id, T) {
    let depth = 0;
    while(T[id].parent !== null) {
        depth += 1;
        id = T[id].parent;
    }
    return depth;
}

function getHeight(id, T) {
    let lefth = 0;
    let righth = 0;
    if(T[id].left > -1) {
        lefth = getHeight(T[id].left, T) + 1;
    }
    if(T[id].right > -1) {
        righth = getHeight(T[id].right, T) + 1;
    }
    return Math.max(lefth, righth);
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));

