package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type Node struct {
	parent, left, right int
}

const NIL = -1

var T [25]Node
var D [25]int
var H [25]int

func setDepth(u, p int) {
	D[u] = p
	if T[u].right != NIL {
		setDepth(T[u].right, p+1)
	}
	if T[u].left != NIL {
		setDepth(T[u].left, p+1)
	}
}

func setHeight(u int) int {
	h1, h2 := 0, 0
	if T[u].right != NIL {
		h1 = setHeight(T[u].right) + 1
	}
	if T[u].left != NIL {
		h2 = setHeight(T[u].left) + 1
	}
	H[u] = max(h1, h2)
	return H[u]
}

func getChildren(u int) []int {
	res := []int{}
	if T[u].left != NIL {
		res = append(res, T[u].left)
	}
	if T[u].right != NIL {
		res = append(res, T[u].right)
	}
	return res
}

func getSibling(u int) int {
	res := NIL
	if T[u].parent != NIL {
		for _, c := range getChildren(T[u].parent) {
			if c != u {
				res = c
			}
		}
	}
	return res
}

func getType(u int) string {
	if T[u].parent == NIL {
		return "root"
	} else if len(getChildren(u)) != 0 {
		return "internal node"
	} else {
		return "leaf"
	}
}

func printNode(w io.Writer, u int) {
	fmt.Fprint(w, "node ", u, ": ")
	fmt.Fprint(w, "parent = ", T[u].parent, ", ")
	fmt.Fprint(w, "sibling = ", getSibling(u), ", ")
	fmt.Fprint(w, "degree = ", len(getChildren(u)), ", ")
	fmt.Fprint(w, "depth = ", D[u], ", ")
	fmt.Fprint(w, "height = ", H[u], ", ")
	fmt.Fprint(w, getType(u))
	fmt.Fprintln(w)
}

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	for i := 0; i < N; i++ {
		T[i] = Node{NIL, NIL, NIL}
	}
	for i := 0; i < N; i++ {
		id, l, r := sc.nextInt(), sc.nextInt(), sc.nextInt()
		T[id].left = l
		T[id].right = r
		if l != NIL {
			T[l].parent = id
		}
		if r != NIL {
			T[r].parent = id
		}
	}
	var root int
	for i := 0; i < N; i++ {
		if T[i].parent == NIL {
			root = i
		}
	}
	setDepth(root, 0)
	setHeight(root)

	for i := 0; i < N; i++ {
		printNode(wtr, i)
	}
	wtr.Flush()
}



Measured memory_bytes: 1120