class Tree {
  static get Node() {
    return class {
      constructor(id, parentId, childrenIds, type, depth) {
        this.id = id;
        this.parentId = parentId;
        this.childrenIds = childrenIds;
        this.type = type;
        this.depth = depth;
      }

      toString() {
        return `node ${this.id}: parent = ${this.parentId}, depth = ${this.depth}, ${this.type}, [${this.childrenIds}]`;
      }
    };
  }

  constructor() {
    this.nodes = [];
  }

  add(id, childrenIds) {
    this.nodes[id] = this.nodes[id] || new Tree.Node(id, -1, childrenIds, 'root', 0);
    let node = this.nodes[id];
    node.childrenIds = childrenIds;

    let c;
    if (childrenIds.length !== 0) {
      childrenIds.forEach((cid) => {
        c = new Tree.Node(cid, id, [], `leaf`, node.depth + 1);
        this.nodes[cid] = c;
      });
      node.type = 'internal node';
    }
  }

  print() {
    console.log(this.nodes.sort((a, b) => a.id - b.id).map(n => n.toString()).join('\n'));
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  let tree = new Tree();

  let id, k, childrenIds;
  lines.map(l => l.split(' ')).forEach(function(line) {
    id = Number(line.shift());
    k = Number(line.shift());
    childrenIds = line.map(Number);
    tree.add(id, childrenIds);
  });

  tree.print();
})();

