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 n [] = [0]
solve n ((root, target, distance) : routes) = runST $ do
    vec <- MV.replicate n Nothing
    MV.write vec (root - 1) (Just 0)
    MV.write vec (target - 1) (Just distance)
    forM_ routes $ \(nodeA, nodeB, distance) -> do
        distanceToA <- MV.read vec (nodeA - 1)
        case distanceToA of
            Nothing -> do
                distanceToB <- MV.read vec (nodeB - 1)
                case distanceToB of
                    Nothing -> pure ()
                    Just b -> MV.write vec (nodeA - 1) $ Just (b + distance)
            Just a -> MV.write vec (nodeB - 1) $ Just (a + distance)
    forM [0..(n-1)] $ \i -> do
        distanceToNode <- MV.read vec i
        case distanceToNode of
            Nothing -> pure 0
            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 n routes) print 
