module Main where

import Debug.Trace
import Data.List
import qualified Data.Sequence as S
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Char
import Data.Array
import Data.Maybe
import qualified Data.Map as M
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad
import Text.Printf

solve :: Int -> [[Int]] -> [(Int, Int, Int, Int, Int, Int, String)]
solve n lst = sort (iter 0 (-1) root) where
    iter depth parent node = info:(concatMap (iter (depth+1) node) (children)) where
        info :: (Int, Int, Int, Int, Int, Int, String)
        info = (node, parent, sibling, degree, depth, height,
                case node of
                 _  | node == root  -> "root"
                    | degree == 0   -> "leaf"
                    | otherwise     -> "internal node")

        sibling = if parent >=0 then
                                 if null sl then -1 else head sl
                                else -1
        degree  = length children
        height  = getHeight node
        children = siblings node
        sl = filter (/=node) (siblings parent)

    getHeight x
        | length children == 0 = 0
        | otherwise = 1 + (maximum (map getHeight children)) where
            children = siblings x

    siblings p = iter [] (n-1) where   -- p: parent 
        iter sc (-1) = sc
        iter sc i 
            | tree!i == p = iter (i:sc) (i-1)
            | otherwise = iter sc (i-1) 

    root = iter 0 where
        iter x 
            | tree!x == -1 = x
            | otherwise = iter (tree!x)

    tree :: Array Int Int
    tree = iter [] (sort lst) where
        iter ac [] = (listArray (0, n-1) (replicate n (-1))) // ac
        iter ac ([x,(-1),(-1)]:ns) = iter ac ns 
        iter ac ([x,l,(-1)]:ns) = iter ((l, x):ac) ns 
        iter ac ([x,(-1),r]:ns) = iter ((r, x):ac) ns 
        iter ac ([x,l,r]:ns) = iter ((l, x):(r, x):ac) ns 

readIntLn:: IO Int
readIntLn = (fst . fromJust . B.readInt) <$> B.getLine

readIntList:: IO [Int]
readIntList = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

print' (n, p, s, deg, dep, h, t) =  
    putStrLn $ "node "++show n++": parent = "++show p++", sibling = "++show s++", degree = "++show deg++", depth = "++show dep++", height = "++show h++", "++t

main :: IO() 
main = do
    n <- readIntLn
    l <- replicateM n readIntList
    mapM_ print' $ solve n l 

