#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
const double EPS=1e-7;
const int MOD=1e9+7;
#define int int64_t
#define double long double
// typedef
#define vdef(t,T) typedef vector<t> V##T;typedef vector<V##T> VV##T;
#define pdef(t1,t2,T) typedef pair<t1,t2> P##T;vdef(P##T,P##T)
vdef(int,I)vdef(double,D)vdef(char,C)vdef(string,S)pdef(int,int,II)pdef(int,PII,III)
#define VCL vector<C>
#define PCC pair<C1,C2>
// define use frequently
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define mp make_pair
#define mp3(a,b,c) mp(a,mp(b,c))
#define fi first
#define se second
#define fir fi
#define sec se.fi
#define thi se.se
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define range(vec,x,y) vec.begin()+x,vec.begin()+y
#define sortup(vec) sort(all(vec))
#define sortdown(vec) sort(lla(vec))
#define eraseif(vec,condition_VAR) vec.erase(remove_if(all(vec),[&](auto VAR){return condition_VAR;}),vec.end())
#define erase_unique(vec) vec.erase(unique(all(vec)),vec.end())
#define rotateleft(vec,n) rotate(vec.begin(),vec.begin()+n,vec.end())
#define rotateright(vec,n) rotate(vec.rbegin(),vec.rbegin()+n,vec.rend())
template<class C>int minelement(VCL&vec){int s=si(vec);C m=0;fou(i,1,s)if(vec[i]<vec[m])m=i;return m;}
template<class C>int maxelement(VCL&vec){int s=si(vec);C m=0;fou(i,1,s)if(vec[i]>vec[m])m=i;return m;}
template<class C>void mini(C&a,const C&b){a=min(a,b);}
template<class C>void maxi(C&a,const C&b){a=max(a,b);}
// make_pair,vector calculate
#define opall(calc) calc(+)calc(-)calc(*)calc(/)calc(%)calc(<<)calc(>>)calc(&)calc(|)calc(^)
#define p1c(op) template<class C1,class C2,class CC>PCC operator op(const PCC&l,const CC&r){return mp(l.fi op r,l.se op r);}
#define p2c(op) template<class C1,class C2>PCC operator op(const PCC l,const PCC&r){return mp(l.fi op r.fi,l.se op r.se);}
#define v1c(op) template<class C,class CC>VCL operator op(VCL l,const CC&r){int s=si(l);fou(i,0,s)l[i]=l[i] op r;return l;}
#define v2c(op) template<class C>VCL operator op(VCL l,const VCL&r){int s=min(si(l),si(r));fou(i,0,s)l[i]=l[i] op r[i];return l;}
#define opeq(op) template<class C1,class C2>C1 operator op##=(C1&l,const C2&r){return l=l op r;}
opall(p1c)opall(p2c)opall(v1c)opall(v2c)opall(opeq)
// iostream
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__)
#define out(...) _cout(__VA_ARGS__)
void _cin(){}template<class Head,class...Tail>void _cin(Head&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
template<class Head>void _cout(const Head&head){cout<<head<<endl;}template<class Head,class...Tail>void _cout(const Head&head,Tail...tail){cout<<head<<" ";_cout(forward<Tail>(tail)...);}
template<class C1,class C2>istream&operator>>(istream&is,PCC&p){return is>>p.fi>>p.se;}
template<class C>istream&operator>>(istream&is,VCL&vec){tra(v,vec)is>>v;return is;}
template<class C1,class C2>ostream&operator<<(ostream&os,const PCC&p){os<<p.fi<<" "<<p.se;return os;}
template<class C>ostream&operator<<(ostream&os,const VCL&vec){int vecsize=si(vec);fou(i,0,vecsize-1)os<<vec[i]<<" ";os<<vec[vecsize-1];return os;}
// math
template<class C>C sign(C a){return (a>0)-(a<0);}
int gcd_sub(const int&a,const int&b){if(b)return gcd_sub(b,a%b);else return a;}int gcd(const int&a,const int&b){return gcd_sub(max(a,b),min(a,b));}
int lcm(const int&a,const int&b){return a/gcd(a,b)*b;}
int fact(const int&n){return n==0?1:n*fact(n-1);}
PII comb_sub(const int&m,const int&n){return n==0?mp((int)1,(int)1):mp(m,n)*comb_sub(m-1,n-1);}int comb(const int&m,const int&n){PII p=comb_sub(m,min(n,m-n));return p.fi/p.se;}
int mnum(const int&a){return a%MOD+(a<0?MOD:0);}
int minv(int a){a=mnum(a);int b=MOD,u=0,v=1;while(a>1){u-=b/a*v;b%=a;swap(a,b);swap(u,v);}return mnum(v);}
int madd(const int&a,const int&b){return (mnum(a)+mnum(b))%MOD;}
int msub(const int&a,const int&b){return (mnum(a)-mnum(b))%MOD;}
int mmul(const int&a,const int&b){return (mnum(a)*mnum(b))%MOD;}
int mdiv(const int&a,const int&b){return mmul(a,minv(b));}
int mpow(int a,int b){int r=1;while(b>0){if(b&1)r=mmul(r,a);a=mmul(a,a);b>>=1;}return r;}
// algorithm
template<class C>vector<C>cumsum(vector<C>vec){int s=si(vec);fou(i,1,s)vec[i]+=vec[i-1];return vec;}
template<class C>vector<vector<C>>cumsum2(vector<vector<C>>vec){int s=si(vec);fou(i,1,s)vec[i]+=vec[i-1];fou(i,0,s)vec[i]=cumsum(vec[i]);return vec;}
template<class C>int binarysearch(const vector<C>vec,const C&n,const char&c){
  int left=-1;int right=si(vec);bool outleft=(c=='d'||c=='U');int getmin=(c=='u'||c=='d')?1:-1;
  while(right-left>1){
    int mid=left+(right-left)/2;
    bool OK=vec[mid]*getmin>=n*getmin;
    if(outleft==OK) left=mid;else right=mid;
  }
  return outleft?left:right;
}

// class unionfind{vector<int> p;int n;public:unionfind(int _n):n(_n){p.resize(n);iota(all(p),0);}int get(const int&x){return (x==p[x]?x:(p[x]=get(p[x])));}void unite(int x,int y){x=get(x);y=get(y);if(x!=y)p[x]=y;}bool same(int x,int y){x=get(x);y=get(y);return x==y;}};
template<class C>class BIT{VCL tree;int n;public:BIT(int _n):n(_n){tree.resize(n);}void add(int x,C v){while(x<n){tree[x]+=v;x|=(x+1);}}C sum(int x){C v=0;while(x>=0){v+=tree[x];x=(x&(x+1))-1;}return v;}C part(int x,int y){return sum(y-1)-sum(x-1);}C get(int x){return part(x,x+1);}void set(int x,int y){add(x,-get(x)+y);}};




class unionfind{
  vector<int> p;int n;public:unionfind(int _n):n(_n){p.resize(n);iota(all(p),1);}
  int get(const int&x){
    return p[x]==(x+1)?(x+1):(p[x]=sign(p[x])*get(abs(p[x])-1));
  }
  void unite(int x,int y){
    x=get(x);y=get(y);
    if(abs(x)!=abs(y))p[abs(x)-1]=y*sign(x);
  }
  void separate(int x,int y){
    x=get(x);y=get(y);
    if(abs(x)!=abs(y))p[abs(x)-1]=-y*sign(x);
  }
  bool same(int x,int y){
    x=get(x);y=get(y);
    return x==y;
  }
  bool diff(int x,int y){
    x=get(x);y=get(y);
    return x==-y;
  }
};


// printf("%.10f\n",ans);

signed main(){IOS;
  in(int,n);
  VPIII uvw(n-1,mp3(0,0,0));
  cin>>uvw;

  unionfind uf(n);
  // out(uf.get(0),uf.get(1),uf.get(2),uf.get(3),uf.get(4),uf.get(5),uf.get(6));
  fou(i,0,n-1){
    if(uvw[i].thi%2==0) uf.unite(uvw[i].fir-1,uvw[i].sec-1);
    else uf.separate(uvw[i].fir-1,uvw[i].sec-1);
    // out(uf.get(0),uf.get(1),uf.get(2),uf.get(3),uf.get(4),uf.get(5),uf.get(6));
  }

  fou(i,0,n) out(uf.same(0,i)?1:0);




  // unionfind uf(10);
  // uf.separate(0,1);
  // uf.separate(2,3);
  // uf.separate(1,2);
  // uf.unite(8,6);
  // out(uf.get(0),uf.get(1),uf.get(2),uf.get(3),uf.get(4),uf.get(5),uf.get(6),uf.get(7),uf.get(8));

}

Measured memory_bytes: 3840