import sys
from heapq import heappush, heappop

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *UVW = map(int, read().split())
    G = [[] for _ in range(N)]
    for u, v, w in zip(*[iter(UVW)] * 3):
        G[u - 1].append((v - 1, w))
        G[v - 1].append((u - 1, w))

    dist = [INF] * N
    dist[0] = 0
    hq = [(0, 0)]

    while hq:
        d, v = heappop(hq)
        if d > dist[v]:
            continue
        for nv, cost in G[v]:
            if dist[nv] > dist[v] + cost:
                dist[nv] = dist[v] + cost
                heappush(hq, (dist[nv], nv))

    ans = [0] * N
    for i in range(N):
        ans[i] = 0 if dist[i] % 2 == 0 else 1

    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main() import sys sys from heapq import heappush, heappop read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 1 << 60 INF 1 << 60 1 60 MOD = 1000000007 MOD 1000000007 def main():
    N, *UVW = map(int, read().split())
    G = [[] for _ in range(N)]
    for u, v, w in zip(*[iter(UVW)] * 3):
        G[u - 1].append((v - 1, w))
        G[v - 1].append((u - 1, w))

    dist = [INF] * N
    dist[0] = 0
    hq = [(0, 0)]

    while hq:
        d, v = heappop(hq)
        if d > dist[v]:
            continue
        for nv, cost in G[v]:
            if dist[nv] > dist[v] + cost:
                dist[nv] = dist[v] + cost
                heappush(hq, (dist[nv], nv))

    ans = [0] * N
    for i in range(N):
        ans[i] = 0 if dist[i] % 2 == 0 else 1

    print(*ans, sep='\n')
    return main N, *UVW = map(int, read().split()) N map(int, read().split()) map int read().split() ().split () read split *UVW UVW [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] G = [[] for _ in range(N)] G [[] for _ in range(N)] for u, v, w in zip(*[iter(UVW)] * 3):
        G[u - 1].append((v - 1, w))
        G[v - 1].append((u - 1, w))

     u v w zip(*[iter(UVW)] * 3) zip *[iter(UVW)] * 3 [iter(UVW)] * 3 [iter(UVW)] iter(UVW) iter UVW 3 G[u - 1].append((v - 1, w)) [u - 1].append [u - 1] G u - 1 u 1 append (v - 1, w) v - 1 v 1 w G[v - 1].append((u - 1, w)) [v - 1].append [v - 1] G v - 1 v 1 append (u - 1, w) u - 1 u 1 w dist = [INF] * N dist [INF] * N [INF] INF N dist[0] = 0 dist[0] dist 0 0 hq = [(0, 0)] hq [(0, 0)] (0, 0) 0 0 while hq:
        d, v = heappop(hq)
        if d > dist[v]:
            continue
        for nv, cost in G[v]:
            if dist[nv] > dist[v] + cost:
                dist[nv] = dist[v] + cost
                heappush(hq, (dist[nv], nv))

     hq d, v = heappop(hq) d heappop(hq) heappop hq v if d > dist[v]:
            continue
         d > dist[v] d dist[v] dist v continue for nv, cost in G[v]:
            if dist[nv] > dist[v] + cost:
                dist[nv] = dist[v] + cost
                heappush(hq, (dist[nv], nv))

     nv cost G[v] G v if dist[nv] > dist[v] + cost:
                dist[nv] = dist[v] + cost
                heappush(hq, (dist[nv], nv))

     dist[nv] > dist[v] + cost dist[nv] dist nv dist[v] + cost dist[v] dist v cost dist[nv] = dist[v] + cost dist[nv] dist nv dist[v] + cost dist[v] dist v cost heappush(hq, (dist[nv], nv)) heappush hq (dist[nv], nv) dist[nv] dist nv nv ans = [0] * N ans [0] * N [0] 0 N for i in range(N):
        ans[i] = 0 if dist[i] % 2 == 0 else 1

     i range(N) range N ans[i] = 0 if dist[i] % 2 == 0 else 1 ans[i] ans i 0 if dist[i] % 2 == 0 else 1 dist[i] % 2 == 0 dist[i] % 2 dist[i] dist i 2 0 0 1 print(*ans, sep='\n') print *ans ans sep='\n' sep '\n' return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main readline = sys.stdin.readline sys.stdin.readline readline INF = 1 << 60 1 << 60 INF def main():
    N, *UVW = map(int, read().split())
    G = [[] for _ in range(N)]
    for u, v, w in zip(*[iter(UVW)] * 3):
        G[u - 1].append((v - 1, w))
        G[v - 1].append((u - 1, w))

    dist = [INF] * N
    dist[0] = 0
    hq = [(0, 0)]

    while hq:
        d, v = heappop(hq)
        if d > dist[v]:
            continue
        for nv, cost in G[v]:
            if dist[nv] > dist[v] + cost:
                dist[nv] = dist[v] + cost
                heappush(hq, (dist[nv], nv))

    ans = [0] * N
    for i in range(N):
        ans[i] = 0 if dist[i] % 2 == 0 else 1

    print(*ans, sep='\n')
    return def main():
    N, *UVW = map(int, read().split())
    G = [[] for _ in range(N)]
    for u, v, w in zip(*[iter(UVW)] * 3):
        G[u - 1].append((v - 1, w))
        G[v - 1].append((u - 1, w))

    dist = [INF] * N
    dist[0] = 0
    hq = [(0, 0)]

    while hq:
        d, v = heappop(hq)
        if d > dist[v]:
            continue
        for nv, cost in G[v]:
            if dist[nv] > dist[v] + cost:
                dist[nv] = dist[v] + cost
                heappush(hq, (dist[nv], nv))

    ans = [0] * N
    for i in range(N):
        ans[i] = 0 if dist[i] % 2 == 0 else 1

    print(*ans, sep='\n')
    return main read = sys.stdin.read sys.stdin.read read readlines = sys.stdin.readlines sys.stdin.readlines readlines MOD = 1000000007 1000000007 MOD
import sys
from heapq import heappush, heappop

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *UVW = map(int, read().split())
    G = [[] for _ in range(N)]
    for u, v, w in zip(*[iter(UVW)] * 3):
        G[u - 1].append((v - 1, w))
        G[v - 1].append((u - 1, w))

    dist = [INF] * N
    dist[0] = 0
    hq = [(0, 0)]

    while hq:
        d, v = heappop(hq)
        if d > dist[v]:
            continue
        for nv, cost in G[v]:
            if dist[nv] > dist[v] + cost:
                dist[nv] = dist[v] + cost
                heappush(hq, (dist[nv], nv))

    ans = [0] * N
    for i in range(N):
        ans[i] = 0 if dist[i] % 2 == 0 else 1

    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()
