module Main where

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

solve :: [(Int, Int, Int)] -> Int -> [Int]
solve ((from, to, dist) : routes) nums = runST $ do
    let root = from - 1
    distantVec <- MV.replicate nums []
    MV.write distantVec root [((to -1), dist)]
    forM_ routes $ \(from, to, distance) -> do
        MV.modify distantVec (((to-1),distance):) (from  -1)
        MV.modify distantVec (((from -1 ),distance):) (to -1)
    distanceFromRootVec <- MV.replicate nums (Nothing :: Maybe Int)
    let search point distAccum = do
            MV.write distanceFromRootVec point (Just distAccum)
            routes <- MV.read distantVec point
            forM_ routes $ \(nextPoint, distance) -> do
                dist <- MV.read distanceFromRootVec nextPoint 
                case dist of
                    Just n -> pure ()
                    Nothing -> search nextPoint (distAccum + distance)
    search root 0
    forM [0..(nums-1)] $ \point -> do
        dist <- MV.read distanceFromRootVec point
        case dist of
            Nothing -> pure undefined
            Just n -> pure $ if even n then 0 else 1



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
    routes <- replicateM (n - 1) readTuple3
    forM_ (solve routes n) print 
