module Main where

import Data.List
import Control.Monad
import Debug.Trace
import Data.Char (isNumber)
import qualified Data.Set as S

readTuple :: String -> (Int, Int, Int)
readTuple s = 
    let
        [a,b,c] = words s
    in
        (read a, read b, read c)

solve :: [(Int, Int, Int)] -> Int -> [String]
solve conds n = let
    (setA, setB) = foldr (\(a,b,c) (setA, setB) ->
        if even c then
            (setA, setB)
        else if (S.member a setA) || (S.member b setB) then
            (S.insert a setA, S.insert b setB)
        else
            (S.insert b setA, S.insert a setB)
        ) (S.empty, S.empty) conds
    in 
        map (\t -> if S.member t setB then "1" else "0" ) [1..n]

main = do
    n <- readLn
    conditions <- lines <$> getContents
    let conds = readTuple <$> conditions
    forM_ (solve conds n) putStrLn
