import Control.Applicative
import Data.Array.IArray

type CompBinTree = Array Int Int

main = do
        n <- readLn
        list <- map read.words<$>getLine
        let cbt = listArray (1,n) list :: CompBinTree
        mapM_ (\i -> printIDInfo i cbt) [1..n]

idInfo nid cbt = [key nid cbt, parentKey nid cbt, leftKey nid cbt, rightKey nid cbt]
key :: Int -> CompBinTree -> Maybe Int
key nid cbt = Just $ cbt ! nid

parentKey :: Int -> CompBinTree -> Maybe Int
parentKey nid cbt
    | pid <= 0 = Nothing
    | otherwise = Just $ cbt ! pid
    where pid = nid `div` 2

leftKey :: Int -> CompBinTree -> Maybe Int
leftKey nid cbt
    | not (inBounds lid cbt) = Nothing
    | otherwise              = Just $ cbt ! lid
        where lid = nid * 2

rightKey nid cbt
    | not (inBounds rid cbt) = Nothing
    | otherwise              = Just $ cbt ! rid
    where rid = nid * 2  + 1

inBounds :: (Ix i) => i -> Array i e -> Bool
inBounds i arr = i >= l && i <= r
    where (l,r) = bounds arr

printIDInfo nid cbt = do
        putStr $ "node " ++ show nid ++ ":"
        sequence_ $ zipWith (\f a -> f a) [printKey, printPKey, printLKey, printRKey] (idInfo nid cbt)
        putStrLn ""
printInfo :: (Show a) => String -> Maybe a -> IO ()
printInfo str Nothing = putStr ""
printInfo str (Just x) = putStr $ str ++ show x ++ ", "
printKey :: (Show a) => Maybe a -> IO ()
printKey = printInfo " key = "
printLKey :: (Show a) => Maybe a -> IO ()
printLKey = printInfo " left key = "
printRKey :: (Show a) => Maybe a -> IO ()
printRKey = printInfo " right key = "
printPKey :: (Show a) => Maybe a -> IO ()
printPKey = printInfo " parent key = "