// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <algorithm>

#include <iostream>

#include <vector>

using namespace std;

const int maxn=100005;

struct tree

{

    int parent;

    vector<int>child;

    int depth;

};

tree node[maxn];

int n;

void init()

{

    for (int i=0;i<n;i++)

        node[i].depth=node[i].parent=-1;

}

int Find (int x)

{

    if(node[x].parent==-1)

        return node[x].depth=0;

    else if(node[x].depth!=-1)

        return node[x].depth;

    else

        return Find(node[x].parent)+1;

}

int main()

{

    scanf("%d",&n);

    init();

    for (int i=0;i<n;i++)

    {

        int x,num;

        scanf("%d%d",&x,&num);

        while (num--)

        {

            int y;

            scanf("%d",&y);

            node[y].parent=x;

            node[x].child.push_back(y);

        }

    }

    for (int i=0;i<n;i++)

    {

        printf("node %d: parent = %d, depth = %d, ",i,node[i].parent,node[i].depth=Find(i));

        if(node[i].parent==-1)

            printf("root, ");

        else if(!node[i].child.size())

            printf("leaf, ");

        else

            printf("internal node, ");

        printf("[");

        for (int j=0;j<node[i].child.size();j++)

        {

            printf("%d",node[i].child[j]);

            if(j<node[i].child.size()-1)

                printf(", ");

        }

        printf("]\n");

    }

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 4.404400972679582x):
#include <iostream>

#include <vector>



using namespace std;



const int N = 1e6;



struct TreeNode {

    int id;

    TreeNode* parent;

    TreeNode* child;

    TreeNode* sibling;



    TreeNode(int x): id(x), parent(nullptr), child(nullptr), sibling(nullptr) {}

};



bool isRoot(TreeNode* node) {

    return node->parent == nullptr;

}



bool isLeaf(TreeNode* node) {

    return node->child == nullptr;

}



int getDepth(TreeNode* node) {

    if (isRoot(node))

        return 0;

    else

        return getDepth(node->parent) + 1;

}



int main() {

    int n;

    cin >> n;



    TreeNode* nodes[N];

    for (int i = 0; i < n; i++)

        nodes[i] = new TreeNode(i);



    for (int i = 0; i < n; i++) {

        int id;

        cin >> id;

        int k;

        cin >> k;

        if (k == 0)

            continue;

        vector<int> children(k);

        for (int j = 0; j < k; j++) {

            cin >> children[j];

            if (j == 0)

                nodes[id]->child = nodes[children[j]];

            else

                nodes[children[j - 1]]->sibling = nodes[children[j]];

            nodes[children[j]]->parent = nodes[id];

        }

    }



    for (int i = 0; i < n; i++) {

        cout << "node " << i << ": ";

        

        cout << "parent = ";

        if (isRoot(nodes[i]))

            cout << -1 << ", ";

        else

            cout << nodes[i]->parent->id << ", ";

        

        cout << "depth = " << getDepth(nodes[i]) << ", ";



        if (isRoot(nodes[i]))

            cout << "root" << ", ";

        else if (isLeaf(nodes[i]))

            cout << "leaf" << ", ";

        else

            cout << "internal node" << ", ";



        cout << "[";

        if (nodes[i]->child != nullptr) {

            cout << nodes[i]->child->id;

            TreeNode* p = nodes[i]->child->sibling;

            while (p != nullptr) {

                cout << ", ";

                cout << p->id;

                p = p->sibling;

            }

        }

        cout << "]" << endl;

    }



    for (int i = 0; i < n; i++)

        delete nodes[i];



    return 0;

}