#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <list>
 
enum TNodeType {ntRoot, ntInternal, ntLeaf};
template<typename T>
class TTree;
 
template<typename T>
class TNode
{
    const T FValue;
    TNode* FParent;
    TNode* FFirstChild;
    TNode* FLastChild;
    TNode* FNextSibling;
 
public:
    TNode(const T& Value)
     : FValue(Value)
    {
        FParent      = NULL;
        FFirstChild  = NULL;
        FLastChild   = NULL;
        FNextSibling = NULL;
    }
    T Value()const
    {
        return FValue;
    }
    void AddNode(TNode* Node)
    {
        Node->FParent = this;
        if(FFirstChild){

            FLastChild->FNextSibling = Node;
            FLastChild = Node;
        }else{
            FFirstChild = Node;
            FLastChild  = Node;
        }
    }
    TNode* Add(const T& Value)
    {
        TNode* Node = new TNode(Value);
        AddNode(Node);
        return Node;
    }
    const TNode* Parent()const
    {
        return FParent;
    }
    const TNode* FirstChild()const
    {
        return FFirstChild;
    }
    const TNode* NextSibling()const
    {
        return FNextSibling;
    }
    const TNode* Find(const T& Value)const
    {
        // std::cout << "Find(" << Value << ")" << std::endl;
        if(FValue == Value) return this;
        for(const TNode* Child = FFirstChild; Child; Child = Child->FNextSibling){
            const TNode* Node = Child->Find(Value);
            if(Node) return Node;
        }
        return NULL;
    }
    TNode* Find(const T& Value)
    {
        return const_cast<TNode*>(const_cast<const TNode*>(this)->Find(Value));
    }
};

template<typename T>
int GetNodeDepth(const TNode<T>* Node)
{
    assert(Node);
    int Depth = 0;
    while(Node->Parent()){
        Node = Node->Parent();
        Depth++;
    }
    return Depth;
}
 
template<typename T>
TNodeType GetNodeType(const TNode<T>* Node)
{
    assert(Node);
    if(Node->Parent() == NULL) return ntRoot;
    if(Node->FirstChild())     return ntInternal;
    return ntLeaf;
}
std::string GetNodeTypeText(const TNodeType& Type)
{
    switch(Type){
    case ntRoot:     return "root";
    case ntInternal: return "internal node";
    case ntLeaf:     return "leaf";
    }
    assert(false);
    return "";
}
 
template<typename T>
std::string GetChildrenText(const TNode<T>* Node)
{
    assert(Node);
    std::stringstream ss;
    ss << "[";
    const TNode<T>* Child = Node->FirstChild();
    while(Child){
        ss << Child->Value();
        Child = Child->NextSibling();
        if(Child) ss << ", ";
    }
    ss << "]";
    return ss.str();
}
template<typename T>
void PrintNode(const TNode<T>* Node)
{
    assert(Node);
// node 1: parent = 0, depth = 1, internal node, [2, 3]    
    std::cout << 
    "node "       << Node->Value() <<
    ": parent = " << (Node->Parent() ? Node->Parent()->Value() : -1) <<
    ", depth = "  << GetNodeDepth(Node) <<
    ", "          << GetNodeTypeText(GetNodeType(Node)) <<
    ", "          << GetChildrenText(Node) <<
    std::endl;
}
template<typename T>
void AddChildren(TNode<T>* Node, int k, std::vector<TNode<T>*>& Table)
{
    assert(Node);
    for(int i = 0; i < k; ++i){
        int c;
        std::cin >> c;
        if(Table[c]){
            Node->AddNode(Table[c]);
        }else{
            Table[c] = Node->Add(c);
        }
    }
}
template<typename T>
bool Compare(const TNode<T>* Left, const TNode<T>* Right)
{
    return Left->Value() < Right->Value();
}
int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int n;
    std::cin >> n;
    std::vector<TNode<int>*> Table(100000, NULL);
    for(int i = 0; i < n; ++i){
        int id;
        int k;
        std::cin >> id >> k;
        TNode<int>* Node = Table[id];
        if(Node == NULL){
            Node = new TNode<int>(id);
            Table[id] = Node;
        }
        AddChildren(Node, k, Table);
    }
    for(std::size_t i = 0; i < Table.size(); ++i){
        const TNode<int>* Node = Table[i];
        if(Node == NULL) continue;
        PrintNode(Node);
    }
    return 0;
}

Measured memory_bytes: 9808