const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const inputs = input.trim().split('\n');
const n = Number(inputs.shift());
const adj = inputs.map((s) => s.split(' ').map(Number));


class Node {
  constructor(id, depth) {
    this.id = id;
    this.parent = -1;
    this.depth = depth;
    this.children = [];
  }
  add(node) {
    node.depth = this.depth + 1;
    node.parent = this.id;
    this.children.push(node);
  }
  getType() {
    if (this.depth === 0) {
      return 'root';
    }
    return this.children.length ? 'internal node' : 'leaf';
  }
  toString() {
    return 'node ' + this.id + ': ' + [
      'parent = ' + this.parent,
      'depth = ' + this.depth,
      this.getType(),
      '[' + this.children.map(node => node.id).join(', ') + ']',
    ].join(', ');
  }
}

class Tree {
  constructor() {
    this.map = new Map();
  }
  getNode(id) {
    if (!this.map.has(id)) {
      this.map.set(id, new Node(id, 0));
    }
    return this.map.get(id);
  }
  print(ids) {
    ids.forEach(id => {
      const node = this.map.get(id);
      console.log(node.toString());
    });
  }
}

const ids = [];
const tree = new Tree();
adj.forEach(([id, k, ...ck]) => {
  ids.push(id);
  const parent = tree.getNode(id);
  ck.forEach(c => {
    const node = tree.getNode(c);
    parent.add(node);
  });
});

tree.print(ids);

