// Original C++ solution (slower):
#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;

}




// Optimized solution to the same problem (faster):
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cmath>

using namespace std;

const int MAX = 100005;

const int NIL = -1;





struct Node {

    int p, l, r;

};

Node Tree[MAX];

int n, Depth[MAX];





void print(int u) {

    printf("node %d: ", u);

    printf("parent = %d, ", Tree[u].p);

    printf("depth = %d, ", Depth[u]);



    if (Tree[u].p == NIL)

        printf("root, ");

    else if (Tree[u].l == NIL)

        printf("leaf, ");

    else

        printf("internal node, ");



    printf("[");

    // 浠庡瓙缁撶偣鐨勬渶宸﹁竟寮€濮嬮亶鍘?

    int c = Tree[u].l;

    while (c != NIL) {

        printf("%d", c);

        if (Tree[c].r != NIL)

            printf(", ");

        // 璺冲埌鍙充晶绱ч偦鐨勫厔寮熺粨鐐?

        c = Tree[c].r;

    }

    printf("]\n");

}



// 閫掑綊寰楁眰娣卞害

void rec(int u, int depth) {

    Depth[u] = depth;

    if (Tree[u].r != NIL)  // 鍙充晶鍏勫紵璁剧疆涓虹浉鍚屾繁搴?

        rec(Tree[u].r, depth);

    if (Tree[u].l != NIL)  // 鏈€宸︿晶瀛愮粨鐐圭殑娣卞害璁剧疆涓鸿嚜宸辩殑娣卞害 + 1

        rec(Tree[u].l, depth + 1);

}

int main() {

    int n;

    scanf("%d", &n);



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

        Tree[i].p = Tree[i].l = Tree[i].r = NIL;

    }

    int v, num, c, l, root;

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

        // v鏄綋鍓嶇粨鐐瑰€?锛宯um鏄痸缁撶偣鐨勫瓙缁撶偣鏁?

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

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

            scanf("%d", &c);



            //璁剧疆鏈€宸︿晶缁撶偣 鍜?绱ч偦鍙充晶鍏勫紵缁撶偣

            // l璁板綍鐨勬槸涓婁竴涓粨鐐癸紝灏嗗綋鍓嶇殑缁撶偣璁剧疆涓簂鐨勭揣閭诲彸渚х粨鐐?

            if (j == 0)

                Tree[v].l = c;

            else

                Tree[l].r = c;

            l = c;

            // 璁剧疆鐖剁粨鐐?

            Tree[c].p = v;

        }

    }

    // 鎵惧嚭鏍圭粨鐐?

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

        if (Tree[i].p == NIL)

            root = i;

    }



    rec(root, 0);

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

        print(i);

    return 0;

}


// Fastest known solution for this problem: