import std.stdio, std.conv, std.array, std.string, std.algorithm, std.range;
// from https://ei1333.github.io/luzhiled/snippets/structure/union-find.html
class UnionFind {
  public:
    long[] par;

    this(long size) {
      par = new long[](size);
      foreach (i; 0..size) {
        par[i] = -1;
      }
    }

    long size(long x) {
      return -(par[find(x)]);
    }

    long find(long x) {
      if (par[x] < 0) {
        return x;
      }
      par[x] = find(par[x]);
      return par[x];
    }

    bool same(long x, long y) {
      return !unite(x, y);
    }

    bool unite(long x, long y) {
      x = find(x);
      y = find(y);

      if (x == y) {
        return false;
      }
      if (par[x] > par[y]) {
        par[y] += par[x];
        par[x] = y;
      } else {
        par[x] += par[y];
        par[y] = x;
      }
      return true;
    }
}

void main() {
    long n;
    readf("%d\n", &n);

    auto uf = new UnionFind(n);

    foreach (_; 0..n-1) {
        long u, v, w;
        readf("%d %d %d\n", u, v, w);
        if (w % 2 == 0) {
            uf.unite(u-1, v-1);
        }
    }

    foreach (i; 0..n) {
        if (uf.same(i, 0)) {
            writeln("1");
        } else {
            writeln("0");
        }
    }
}
