import qualified Data.ByteString.Char8 as B
import Data.Maybe(fromJust)
import Control.Arrow
main=putStrLn.unwords.map show.solve.map(fst.fromJust.B.readInt).B.words=<<B.getContents
solve(n:xs)=if odd n then reverse ys++zs else reverse zs++ys where(ys,zs)=(f odd&&&f even)xs
f g=map snd.filter(g.fst).zip[1..]