#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
//#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
//#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;


struct Node{
    int parent=-1;
    vector<int> child;
};

class RootedTree{
    vector<Node> tree;
    vector<int> tree_depth;
    public:
    RootedTree(int n){
        this->tree.resize(n);
        this->tree_depth.resize(n,-1);
    }
    RootedTree(){
        this->tree.resize(10e6);
        this->tree_depth.resize(10e6,-1);
    }

    void make_leaf(int parent,int child){
        tree[parent].child.push_back(child);
        tree[child].parent = parent;
    }

    int depth(int n){
        if(tree_depth[n] != -1) return tree_depth[n];
        int tmp = n;
        //根を探索
        while(tree[tmp].parent != -1){
            tmp = tree[tmp].parent;
        }
        tree_depth[tmp] = 0;
        queue<int> q;
        REP(i,tree[tmp].child.size()){
            q.push(tree[tmp].child[i]);
        }
        while(!q.empty()){
            tmp = q.front();
            q.pop();
            tree_depth[tmp] = tree_depth[tree[tmp].parent]+1;
            REP(i,tree[tmp].child.size()){
                q.push(tree[tmp].child[i]);
            }
        }
        return tree_depth[n];
    }
    void Deb(){
        Debug(tree_depth);
    }
    void print_AOJ(){
        REP(i,tree.size()){
            cout << "node " << i << ": parent = " << tree[i].parent << ", depth = " << depth(i) << ", ";
            if(tree[i].parent == -1) cout << "root";
            else if(tree[i].child.size() == 0) cout << "leaf";
            else cout << "internal node";
            cout << ", [";
            REP(j,tree[i].child.size()){
                if(j){
                    cout << ", ";
                }
                cout << tree[i].child[j];
            }
            cout << "]\n";
        }
    }

};



void print_AOJ(auto a){
    REP(i,a.size()){
        if(i){
            cout << " ";
        }
        cout << a[i];
    }
    cout << "\n";
}


signed main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    cin >> n;
    RootedTree r(n);
    int id,k,c;
    REP(i,n){
        cin >> id >> k;
        REP(j,k){
            cin >> c;
            r.make_leaf(id,c);
        }
    }
    r.print_AOJ();

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 7440