#include <stdio.h>
#include <vector>
#include <list>
#include <map>
#include <array>
#include <memory>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <stdexcept>


using std::string;
using std::vector;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// util
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// user func
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void printList(const vector<int>& list) {
    // print
    for(int i = 0; i < list.size(); i++){
        printf("%d", list[i]);
        if(i != list.size() -1){
            printf(" ");
        }
    }
    printf("\n");
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// logic
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class Node;
using Container = std::map<int, std::shared_ptr<Node>>;
class Node{
private:
    Container *container;
    int id;
    int left;
    int right;
    int parentId;
public:
    Node(Container* container, int id, int left, int right)
        : container(container)
        , id(id)
        , left(left)
        , right(right)
        , parentId(-1)
    {
    }

    int Id(){
        return this->id;
    }
    int Left(){
        return this->left;
    }
    int Right(){
        return this->right;
    }

    void ParentId(int id){
        this->parentId = id;
    }

    int ParentId(){
        return this->parentId;
    }

    int Sibling(){
        // root
        if (this->parentId == -1) return -1;
        if (this->Parent()->Left() == this->id) {
            return this->Parent()->Right();
        } else {
            return this->Parent()->Left();
        }
    }

    int Degree(){
        int result = this->left == -1 ? 0 : 1;
        result   += this->right == -1 ? 0 : 1;
        return result;
    }

    int Depth(){
        if(this->parentId == -1){
            return 0;
        }else{
            return this->Parent()->Depth() + 1;
        }
    }

    int Height(){
        if(this->left + this->right == -2) return 0;
        int lHeight = this->left == -1 ? 0 : (*this->container)[this->left]->Height();
        int rHeight = this->right == -1 ? 0 : (*this->container)[this->right]->Height();
        return std::max(lHeight, rHeight) + 1;
    }

    string Type(){
        if(this->parentId == -1)
        {
            return "root";
        }
        if(this->left + this->right == -2)
        {
            return "leaf";
        }
        else
        {
            return "internal node";
        }
    }

    std::shared_ptr<Node> Parent(){
        if(this->parentId == -1) return nullptr;
        return (*this->container)[this->parentId];
    }
    
};

void solve() {
    // binary trees
    int n;
    scanf("%d", &n);
    Container container;
    for(int i = 0; i < n; i++){
        int id;
        int left, right;
        scanf("%d %d %d", &id, &left, &right);
        auto node = std::make_shared<Node>(&container, id, left, right);
        container.insert(std::make_pair(id, node));
    }
    // set parent
    for(auto& each: container){
        if(each.second->Left() != -1){
            container[each.second->Left()]->ParentId(each.second->Id());
        }
        if(each.second->Right() != -1){
            container[each.second->Right()]->ParentId(each.second->Id());
        }
    }
    for(auto each: container){
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", 
        each.first,
        each.second->ParentId(),
        each.second->Sibling(),
        each.second->Degree(),
        each.second->Depth(),
        each.second->Height(),
        each.second->Type().c_str());
    }
    
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// main
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3340