#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323


class Node {
    public:
        int id = -1;
        Node* parent = nullptr;
        vector<Node*> child;
        string getNodeType(){
            if(getParent() == -1){
                return "root";
            }
            if(child.empty())return "leaf";
            else return "internal node";
        }
        int getDepth() {
            Node* tmp = parent;
            int count = 0;
            while(tmp != nullptr){
                tmp = tmp->parent;
                count++;
            }
            return count;
        }
        int getParent() {
            if(parent==nullptr)return -1;
            else return parent->id;
        }
        void setChild(Node& _child){
            _child.parent = this;
            child.push_back(&_child);
        }
        void printChild() {
            cout << "[";
            for(int i = 0;i<child.size();i++){
                cout << child[i]->id;
                if(i != child.size()-1)cout << ", ";
            }
            cout << "]";
        }
};

void testNode() {
    vector<Node> nodelist(10);

    for(int i =0;i < nodelist.size();i++){
        cout << "node " << nodelist[i].id << ":" << space;
        cout << "parent = " << nodelist[i].getParent() << ", ";
        cout << "depth = " << nodelist[i].getDepth() << ", ";
        cout << nodelist[i].getNodeType() << ", ";
        cout << "[";
        for(int j = 0;j < nodelist[i].child.size();j++){
            cout << nodelist[i].child[j];
            if(j != nodelist[i].child.size()-1) cout << ", ";

        }
        cout << "]" << endl;
    }
}

#define TST 0

int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    //testNode();
    long n;
    cin >> n;
    vector<Node> nodelist(n);
    for( int i = 0;i < n;i++ ){
        int id;
        cin >> id;
        nodelist[id].id = id;
        int childlen;
        cin >> childlen;
        for( int j = 0;j < childlen;j++ ){
            int tmp;
            cin >> tmp;
            nodelist[id].setChild(nodelist[tmp]);
        }
    }

    for(int i =0;i < nodelist.size();i++){
        cout << "node " << nodelist[i].id << ":" << space;
        cout << "parent = " << nodelist[i].getParent() << ", ";
        cout << "depth = " << nodelist[i].getDepth() << ", ";
        cout << nodelist[i].getNodeType() << ", ";
        nodelist[i].printChild();
        cout << endl;
    }
#if TST==1

#endif
}




Measured memory_bytes: 8132