module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.Vector.Mutable as MV
import Control.Monad.ST (runST)

readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- words <$> getLine
    return (read a, read b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- words <$> getLine
    return (read a, read b, read c)

main = do
    n <- readLn
    distantVec <- MV.replicate n []
    let root = 0
    replicateM_ (n - 1) $ do
        (from, to, distance) <- readTuple3
        MV.modify distantVec (((to-1), distance):) (from  -1)
        MV.modify distantVec (((from-1), distance):) (to  -1)
    distanceFromRootVec <- MV.replicate n  (negate 1)
    let search point distAccum = do
            MV.write distanceFromRootVec point distAccum
            routes <- MV.read distantVec point
            forM_ routes $ \(nextPoint, distance) -> do
                dist <- MV.read distanceFromRootVec nextPoint 
                if dist == -1 then pure () 
                else search nextPoint (distAccum + distance)
    search root 0
    forM [0..(n - 1)] $ \point -> do
        dist <- MV.read distanceFromRootVec point
        print $ if even dist then 0 else 1