function main(_stdin) {
    const stdin = _stdin.trim().split('\n');
    const n =  Number(stdin.shift());
    const T = [];
    for (let i = 0, l = stdin.length; i < l; i++) {
        T[i] = {parent: null, left: null, right: null};
    }

    for (const item of stdin) {
        const it = item.split(' ').map(Number);
        if (it.length > 2) {
            const children = it.slice(2);
            T[it[0]].left = children[0];
            for (let i = 0, l = children.length; i < l; i++) {
                T[children[i]].parent = it[0];
                if (children[i + 1] !== undefined) {
                    T[children[i]].right = children[i + 1];
                }
            }
        }
    }

    for (let i = 0, l = T.length; i < l; i++) {
        let type = T[i].parent === null ? 'root' : T[i].left === null ? 'leaf' : 'internal node';
        let children = T[i].left !== null ? getChildren(T[i].left, T) : '';
        let depth = getDepth(i, T);
        console.log(`node ${i}: parent = ${T[i].parent === null ? -1 : T[i].parent}, depth = ${depth}, ${type}, [${children}]`);
    }
}

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

function getChildren(id, T){
    let children = `${id}`;
    while (T[id].right !== null) {
        children += `, ${T[id].right}`;
        id = T[id].right;
    }
    return children;
}

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

