let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', function() {
    const input = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    printNodes(input.shift(), sortWithFormat(input));
});




// const _printNodes = (n, nodeArr) => {
//   let tree;
//   const arrForPrint = new Array(n);

//   for (let i=0; i<n; i++) {
//     const {
//       id,
//       numberOfDegrees,
//       children,
//     } = nodeArr[i];

//     if (i === 0) {
//       const node = {
//         node: id,
//         parent: -1,
//         depth: 0,
//         type: 'root',
//         children,
//       };
//       tree = node;
//       arrForPrint[id] = node;
//       continue;
//     }

//     let depth = 1;
//     let parent = tree;
//     while (true) {
//       console.log(`parent.node ${parent.node}`);
//       if (parent.children.includes(id)) {
//         const node = {
//           node: id,
//           parent: parent.node,
//           depth,
//           type: numberOfDegrees === 0 ? 'leaf' : 'internal node',
//           children,
//         };
//         parent[id] = node;
//         arrForPrint[id] = node;
//         break;
//       }

//       let nextParentId;
//       const cands = [...parent.children].sort((a,b) => a-b);
//       // console.log(cands);
//       for (let j=0; j<cands.length; j++) {
//         const nextParentIdCand = cands[j];
//         if (typeof nextParentIdCand === 'undefined') break;
//         if (id < nextParentIdCand) break;
//         nextParentId = nextParentIdCand;
//         // nextParentId = parent[parent.children[j]].node;
//         // console.log(`nextParentId: ${nextParentId}`);
//         // const _j = parent.children[j+1];
//         // console.log(`_j: ${_j}`);
//         // if (!parent.children[j+1]) break;
//         // if (parent[parent.children[j+1]].node > id) break;
//       }
      
//       parent = parent[nextParentId];
//       // console.log(`parent: ${parent}`);
//       depth++;
//     }
//   }

//   arrForPrint.forEach(printNode);
// };

const printNodes = (n, nodeArr) => {
  let rootCandidates = {};

  for (let i=0; i<n; i++) {
    const currentNode = nodeArr[i];
    if (currentNode.isChild) {
      continue;
    }

    const {
      id,
      children,
    } = currentNode;
    const cand = {
      node: id,
      children,
    };
    children.forEach((child) => {
      cand[child] = createTree(child, nodeArr, rootCandidates);
    });
    rootCandidates[id] = cand;

    // children.forEach((child) => {
    //   const childTree = rootCandidates[child];
    //   delete rootCandidates[child];
    //   nodeArr[child].isChild = true;

    //   if (childTree) {
    //     rootCandidates[id][child] = childTree;
    //   } else {
    //     rootCandidates[id][child] = createTree(child, nodeArr);  
    //   }
    // });
  }

  const rootId = Object.keys(rootCandidates)[0];
  // console.log(`rootCandidates: ${JSON.stringify(rootCandidates)}`);
  // console.log(`rootId: ${rootId}`);
  const tree = rootCandidates[rootId];
  const arrForPrint = new Array(n);
  assignTreeToArr(tree, arrForPrint);
  arrForPrint.forEach(printNode);
};

const createTree = (id, nodeArr, rootCandidates) => {
  delete rootCandidates[id];
  nodeArr[id].isChild = true;

  const node = nodeArr[id];
  const tree = {
    node: id,
    children: node.children,
  };

  node.children.forEach((child) => {
    tree[child] = createTree(child, nodeArr, rootCandidates);
  });

  return tree;
};

const assignTreeToArr = (tree, arr, depth = 0, parent = -1) => {
  let type;
  if (parent === -1) {
    type = 'root';
  } else {
    type = tree.children.length === 0 ? 'leaf' : 'internal node';
  }
  const node = {
    node: tree.node,
    parent,
    children: tree.children,
    depth,
    type,
  };
  arr[tree.node] = node;
  node.children.forEach((child) => {
    assignTreeToArr(tree[child], arr, depth + 1, tree.node);
  });
};

const printNode = (n) => {
  console.log(`node ${n.node}: parent = ${n.parent}, depth = ${n.depth}, ${n.type}, [${n.children.join(', ')}]`);
};

// const formatInput = (arr) => {
//   return arr.map((str) => {
//     const nodeInfo = str.split(' ');
//     return {
//       id: Number(nodeInfo.shift()),
//       numberOfDegrees: Number(nodeInfo.shift()),
//       children: nodeInfo.map((s) => Number(s)),
//     };
//   });
// };

const sortWithFormat = (arr) => {
  const sorted = new Array(arr.length);
  arr.forEach((str) => {
    const nodeInfo = str.split(' ');
    const id = Number(nodeInfo.shift());
    const numberOfDegrees = Number(nodeInfo.shift());
    const children = nodeInfo.map((s) => Number(s));
    sorted[id] = {
      id,
      numberOfDegrees,
      children,
    };
  });
  return sorted;
};
