import Control.Applicative
import Control.Monad.State
import Control.Monad (replicateM, forM_)
import Data.Maybe (fromJust)
data Tree a = Null | Node {number :: a, tchildren :: [Tree a]} deriving (Show, Eq)
data TreeInfo a = TI { parent :: Tree a
                     , cid :: a
                     , depth :: Int
                     , nodeType :: String
                     , children :: [Tree a]
                     } deriving (Show)

main = do
        n <- readLn
        tree <- execStateT (replicateM n setTree) Null :: IO (Tree Int)
        forM_ [0..(n-1)] $ \i -> do
            let dict = getTreeInfo tree
            putStrLn $ showTreeInfo.fromJust.lookup i $ dict

showTreeInfo :: (Eq a, Show a) => TreeInfo a -> String
showTreeInfo ti
    | parent ti == Null = unwords [showNode ti, showParent ti, showDepth ti, "root,", showChildren ti]
    | otherwise         = unwords [showNode ti, showParent ti, showDepth ti, showType ti, showChildren ti]

showNode ti = "node " ++ (show.cid $ ti) ++ ":"
showParent ti
    | parent ti == Null = "parent = -1,"
    | otherwise         = "parent = " ++ (show.number.parent $ ti) ++ ","
showDepth ti = "depth = " ++ (show.depth $ ti) ++ ","
showType ti = nodeType ti ++ ","
showChildren :: (Show a) => TreeInfo a -> String
showChildren = show.map number.children

oneNode cid = Node cid []

setChild :: Eq a => a -> [a] -> Tree a -> Tree a
setChild cid cs Null = Node cid (map oneNode cs)
setChild cid cs (Node i c)
    | i == cid = Node i (map oneNode cs)
    | otherwise = Node i (map (setChild cid cs) c)

addChilds cid cs t = foldr (\c tre -> addChild cid c tre) t cs
addChild cid c (Node i cs)
    | i == cid = Node i (Node c [] :cs)
    | otherwise = Node i (map (addChild cid c) cs)

getTreeInfo t = gti Null 0 t

gti :: Tree a -> Int -> Tree a -> [(a, TreeInfo a)]
gti p d t@(Node i cs)
    | null cs = [(i,TI p i d "leaf" [])]
    | otherwise = (i, TI p i d "internal node" cs) : (concatMap (gti (Node i cs) (d+1)) cs)

setTree = do
        (node:num:cs) <- liftIO $ map read.words<$>getLine
        modify (setChild node cs)