import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad
import Data.Ord(comparing)
import qualified Data.IntMap.Strict as IMap


type Vertex = Int
type Weight = Int

type Graph = IMap.IntMap (U.Vector Edge)
type Edge = (Vertex, Weight)

type VisitedMap = UM.IOVector Bool

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

readAsc :: IO [(Vertex, U.Vector Edge)]
readAsc = do
    [u,v,w] <- r'
    let s = U.singleton
    case even w of
        True -> return [ (u,s (v,0)), (v,s (u,0)) ]
        _    -> return [ (u,s (v,1)), (v,s (u,1)) ]


main :: IO ()
main = do
    n <- readLn :: IO Int
    uvw <- concat <$> replicateM (n-1) readAsc
    let graph = IMap.fromListWith (U.++) uvw :: Graph
    visited <- UM.replicate n False  
    uores <- solve graph visited 0 1
    res <- UM.new n
    U.forM_ uores (\(f,s)->UM.write res (f-1) s)
    forM_ [0..(n-1)] (\x -> do
            v <- UM.read res x
            print v
        )


solve :: Graph -> UM.IOVector Bool -> Weight -> Vertex -> IO (U.Vector Edge)
solve mp visRec curW root = do
    recVisit root visRec
    case IMap.lookup root mp of
        Just xs -> do
            unvisited <- U.filterM ((not <$>) . UM.read visRec . pred . fst) xs
            if unvisited == U.empty
                then do
                    return $ U.singleton (root,curW)
                else do
                    r <- U.foldr' (\(v,w) iob -> do
                                    rest <- solve mp visRec ((w+curW) `mod`2) v
                                    b <- iob
                                    return $ b U.++ rest
                                ) (return U.empty) unvisited 
                    return $ U.cons (root,curW) r
        Nothing -> error ("No entry found for key " ++ show root ++ ".")



recVisit :: Vertex -> UM.IOVector Bool -> IO ()
recVisit v vis = UM.write vis (v-1) True

