
import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromJust)
import Data.List
import qualified Data.Vector.Unboxed.Mutable as V
import Control.Monad
import qualified Data.ByteString.Lazy.Char8 as B
import Debug.Trace

action :: Int -> IO ()
action n = do
  vec <- V.replicate (n+1) 0
  sub vec (n-1)
  forM_ [1..n] $ \i -> do
    c <- V.read vec i
    print c
  where
    sub :: V.IOVector Int -> Int -> IO ()
    sub _ 0 = return ()
    sub vec' n = do
      [u,v,w] <- map read . words <$> getLine
      if even w then return ()
        else do
          color <- V.read vec' u
          if color == 0 then V.write vec' v 1
            else V.write vec' v 0
      sub vec' (n-1)


main :: IO ()
main = do
  n <- readLn :: IO Int
  action n
