jiahuimbzuai/CoQuIR huggingface dataset:
//  [c]
#include <stdio.h>
#include <math.h>
long long min(long long a,long long b){
  if(a>b) return b;
  else return a;
 }

int main(void){
  long long n,d[5],ans,minmove;
  scanf("%lld",&n);

  for(int i=0;i<5;i++) scanf("%lld",&d[i]);
  minmove=min(d[0],min(d[1],(min(d[2],(min(d[3],d[4]))))));
  ans=(long long)ceil((double)n/minmove)+4;

  printf("%lld\n",ans);
  return 0;
}
//  [javascript]
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let a = nextInt()
    let b = nextInt()
    let c = nextInt()
    let d = nextInt()
    let e = nextInt()

    let min = Math.min(a,b,c,d,e)
    let ans = Math.ceil(n/min)
    console.log(ans + 4)

}
Main()
//  [javascript]
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var min = Math.pow(10,15) + 1;
	var A = nextInt();
	min = Math.min(min, A);
	var B = nextInt();
	min = Math.min(min, B);
	var C = nextInt();
	min = Math.min(min, C);
	var D = nextInt();
	min = Math.min(min, D);
	var E = nextInt();
	min = Math.min(min, E);
	if(min >= N){
		myout(5);
	}else{
		var output = Math.floor(N / min);
		if(N % min != 0){
			output++;
		}
		myout(output + 4);
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	n, _ := strconv.Atoi(readLine())
	var v []int
	for i := 0; i < 5; i++ {
		in, _ := strconv.Atoi(readLine())
		v = append(v, in)
	}
	sort.Ints(v)
	if n%v[0] == 0 {
		fmt.Println(n/v[0] + 4)
	} else {
		fmt.Println((n/v[0] + 1) + 4)
	}
}
//  [go]
package main

import "fmt"


func main() {
	var N, tmp uint64
	var A [5]uint64

	fmt.Scan(&N)
	fmt.Scan(&A[0])
	fmt.Scan(&A[1])
	fmt.Scan(&A[2])
	fmt.Scan(&A[3])
	fmt.Scan(&A[4])

	tmp = 10000000000000000
	for i := 0; i < 5; i++ {
		if tmp > A[i] {
			tmp = A[i]
		}
	}

	if N % tmp == 0 {
		fmt.Println(N / tmp + 4)
	} else {
		fmt.Println(N / tmp + 5)
	}
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, A, B, C, D, E int
	fmt.Scan(&N, &A, &B, &C, &D, &E)
	p := []int{A, B, C, D, E}
	sort.Ints(p)
	x := p[0]
    fmt.Println((N-1)/x + 5)
}
//  [ruby]
n=gets.to_i
count=0
all=[]
5.times.each do
    all<<gets.to_i
end

min=all.min
n=(1.0*n/min).ceil
puts n+4
//  [ruby]
line = readlines.map(&:to_i)

N = line.shift

line.sort!

ans = 0
if N % line[0] == 0 then
  ans += N / line[0]
else
  ans += N / line[0] + 1
end

puts ans + 4
//  [ruby]
N = gets.to_i
AE = 5.times.map{|_| gets.to_i}

min = AE.min
ans = N / min + 4 + (N % min == 0 ? 0 : 1)
p ans
//  [rust]
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u64,
        a: u64,
        b: u64,
        c: u64,
        d: u64,
        e: u64,
    }

    println!("{}", (n as f64 / a.min(b.min(c.min(d.min(e)))) as f64).ceil() as u64 + 4);
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        route: [usize;5],
    }

    let mut min_value = route[0];
    for i in route {
        min_value = std::cmp::min(min_value, i);
    }

    let ans = 4 + (((n as f64)/(min_value as f64)).ceil()) as usize;
    // let ans = 5 + n/min_value;
    println!("{}", ans);

}
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}
///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = index(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let (n, a, b, c, d, e) = (readDouble(), readDouble(), readDouble(), readDouble(), readDouble(), readDouble())
    
    print(Int(ceil(n / min(a, b, c, d, e))) + 4)
}
main()
//  [swift]
let n = Int(readLine()!)!
var array: [Int] = []

for _ in 0..<5 {
  let item = Int(readLine()!)!
  array.append(item)
}

var min = array[0]
for i in 1..<5 {
  let item = array[i]
  if item < min {
    min = item
  }
}

let a = n / min
if n % min == 0 {
  print(a+4)
} else {
  print(a+1+4)
}
//  [typescript]
const txt = require('fs').readFileSync('/dev/stdin', 'utf8')

const [n, a, b, c, d, e, gomi] = txt.split('\n').map((i: string) => { return Number(i) })
const min = Math.min(a, b, c, d, e)
if (n % min === 0) {
  console.log(Math.floor(n / min) + 4)
}
else {
  console.log(Math.floor(n / min) + 5)
}
//  [typescript]
import { COPYFILE_FICLONE_FORCE } from 'constants';

namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length == 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  const checkFlag = (f: any) => {
    return f['A'] && f['B'] && f['C'];
  };

  async function slove() {
    const sc = new Scanner();
    const input = [];
    for (let i = 0; i < 6; i += 1) {
      input.push(+(await sc.getLine()));
    }
    const N = input.shift();
    const min = Math.min(...input);
    console.log(Math.ceil(N / min) + 4);

    sc.close();
  }

  slove();
}
//  [python]
n=int(input())
cost = [[] for _ in range(n)]
for _ in range(n-1):
    a, b, c = (int(x) for x in input().split())
    cost[a-1].append([b-1, c])
    cost[b-1].append([a-1, c])

dp = [0]*n

move = [0]
check = [-1]*n
check[0] = 0

while len(move):
    v = move.pop(0)
    for i, j in cost[v]:
        if check[i] == -1:
            dp[i] = dp[v] + j
            check[i] = 1
            move.append(i)
for i in dp:
    print(i%2)
//  [python]
N = int(input())

Dist = [[] for j in range(N)]
Seen = [-1] * N

for i in range(N-1):
    u, v, w = map(int, input().split())
    Dist[u-1].append([v-1, w])
    Dist[v-1].append([u-1, w])

que = [0]
Seen[0] = 0
flag = True
while -1 in Seen:
    now = que.pop()
    for next, distance in Dist[now]:
        if Seen[next] == -1:
            que.insert(0, next)
            if distance % 2 == 0:
                Seen[next] = Seen[now]
            else:
                Seen[next] = 1 - Seen[now]
for i in range(N):
    print(Seen[i])
//  [python]
N=int(input())
uvw=[[] for _ in range(N)]
for i in range(N-1):
    u,v,w=map(int,input().split())
    uvw[u-1].append((v-1,w))
    uvw[v-1].append((u-1,w))
# print(uvw)
color=[-1]*N 
color[0]=0
now=0
nex=[0]
from copy import deepcopy
while nex:
    now=nex.pop()
    stack=deepcopy(uvw[now])
    uvw[now]=[]
    while stack:
        a=stack.pop()
        if a[1]%2==0:
            color[a[0]]=color[now]
        else:
            color[a[0]]=color[now]^1
        nex.append(a[0])
for c in color:
    print(c)
//  [java]
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] d=new int[n];
		Arrays.fill(d,-1);
		Map<Integer,Map<Integer,Integer>> l=new HashMap<>();
		Map<Integer,List<Integer>> m=new HashMap<>();
		for(int i=0;i<n;i++){
			m.put(i,new ArrayList<>());
			l.put(i,new HashMap<Integer,Integer>());
		}
		for(int i=0;i<n-1;i++){
			int u=sc.nextInt()-1;
			int v=sc.nextInt()-1;
			int w=sc.nextInt()%2;
			m.get(u).add(v);
			m.get(v).add(u);
			l.get(u).put(v,w);
			l.get(v).put(u,w);
		}

		d[0]=0;
		Deque<Integer> q=new ArrayDeque<>();
		q.add(0);
		while(q.size()>0){
			int r=q.pollFirst();
			for(int p:m.get(r)){
				if(d[p]!=-1)
					continue;
				d[p]=d[r]+l.get(r).get(p);
				q.offerFirst(p);
			}
		}
		for(int i=0;i<n;i++){
			if(d[i]%2==0)
				System.out.println(0);
			else
				System.out.println(1);
		}
	}
}
//  [java]
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main
{
    public static void main(String[] args)throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//        Scanner input = new Scanner(System.in);
        int n = Integer.parseInt(br.readLine());
        int i,a,b,c;
        int []color = new int[n+1];
        Set<Integer> done = new HashSet<>();
        for(i=1;i<n+1;i++){
            color[i] = 0;
    }
        EvenRataion []mark = new EvenRataion[n+1];
        for(i=1;i<n+1;i++){
            mark[i] = new EvenRataion();
        }
        for(i=0;i<n-1;i++){
            String[] in = br.readLine().split(" ");
            a = Integer.parseInt(in[0]);
            b = Integer.parseInt(in[1]);
            c = Integer.parseInt(in[2]);
            if (c%2==0){
                mark[a].even.add(b);
                mark[b].even.add(a);
            }
            else {
                mark[a].odd.add(b);
                mark[b].odd.add(a);
            }
        }
        List<Integer> run = new ArrayList<>();
        run.add(1);
        List<Integer> temp = new ArrayList<>();
        while (run.size()>0){
            int y = run.get(0);
            run.remove(0);
            done.add(y);
            if (color[y]==0){
                for(int v:mark[y].odd){
                    if(!done.contains(v)){
                        run.add(v);
                        color[v] = 1;
                        temp.add(v);
                    }
                }
                for(int v:mark[y].even){
                    if(!done.contains(v)){
                        temp.add(v);
                    }
                }
            }
            else{
                for(int v:mark[y].even){
                    if(!done.contains(v)){
                        run.add(v);
                        color[v] = 1;
                        temp.add(v);
                    }
                }
                for(int v:mark[y].odd){
                    if(!done.contains(v)){
                        temp.add(v);
                    }
                }

            }
            if(run.size()==0){
                run.addAll(temp);
                temp.clear();
            }
        }
        for(i=1;i<n+1;i++){
            System.out.println(color[i]);
    }
    }
    static class EvenRataion{
        Set<Integer> even = new HashSet<>();
        Set<Integer> odd = new HashSet<>();

    }
}
//  [cpp]
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    int n; cin >> n;

    vector<vector<pair<int, int>>> node;

    for(int i=0; i<n+1; i++){
        vector<pair<int, int>> vemp;
        node.push_back(vemp);
    }


    for(int i=1; i<n; i++){
        int u, v, w;
        cin >> u >> v >> w;
        // cout << u << " " << v << " " << w << endl;
        node[u].push_back(make_pair(v, w));
        node[v].push_back(make_pair(u, w));
    }

    int chk[n+1] = {};
    for(int i=1; i<n; i++){
        for(int j=0; j<node[i].size(); j++){
            chk[node[i][j].first]++;
        }
    }

    int st = 0;
    for(int i=1; i<n; i++){
        if(chk[i] == 1){
            st = i;
        }
    }

    // cout << st << endl;

    stack<int> stk;
    stk.push(st);
    int c[n+1];
    fill(c, c+n+1, -1);
    c[st] = 1;

    while(!stk.empty()){
        int u = stk.top();

        if(node[u].size() == 0){
            stk.pop();
            continue;
        }
        else{
            int v = node[u][0].first;
            int w = node[u][0].second;
            
            if(c[v] == -1){
                // cout << u << " " << v << " " << w << endl;
                
                if(w%2 == 0){
                    c[v] = c[u];
                }
                else{
                    c[v] = 1 - c[u];
                }
            }
            node[u].erase(node[u].begin());
            stk.push(v);
        }
    }

    for(int i=1; i<=n; i++){
        cout << c[i] << endl;
    }



    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#include<limits.h>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace  std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
// #define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
const int LIM = 1e5+5, MOD =  1e9;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); }
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }


bool compare (string s1,string s2)
{
	return s1.length()<s2.length();
}

vp64 v[100004];
ll dis[100004];
void dfs (ll i,ll p)
{
	if (i==1)
	{
		dis[1]=0;
	}
	else
	{
		ll cost;
		for (auto x:v[p])
		{
			if (x.fi==i)
			{
				cost=x.se;
				break;
			}
		}
		if (dis[p]==0&&cost&1)
			dis[i]=1;
		else if (dis[p]==0&&(cost&1)==0)
			dis[i]=0;
		else if ((dis[p]==1&&(cost&1)==1))
			dis[i]=0;
		else
			dis[i]=1;
	}
	for (auto x:v[i])
	{
		if (x.fi==p)
			continue;
		dfs(x.fi,i);
	}
}
int main()
{
	fast;
	ll n;
	cin>>n;
	for (ll i=0;i<n-1;i++)
	{
		ll x,y,z;
		cin>>x>>y>>z;
		v[x].pb({y,z});
		v[y].pb({x,z});
	}
	dfs(1,0);
	for (ll i=1;i<=n;i++)
		cout<<dis[i]<<endl;
	

}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c,d,n,m,x,y,z,k,h,w,sum,mi,ma,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<int, int> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;


struct graph{
    int V;
    vector<VP > v;
    graph(int V) : V(V), v(vector<VP >(V)){}
    void add_diedge(int v1, int v2, ll w){
        v[v1].pb({v2, w});
        v[v2].pb({v1, w});
    }
    void add_edge(int v1, int v2, ll w){
        v[v1].pb({v2, w});
    }
    VL dist = vector<ll>(V, -1);
    VI prever = vector<int>(V,-1);
    VL dijkstra(int start){
        priority_queue<P, vector<P>, greater<P> > que;
        que.push(P(0,start));
        while(!que.empty()){
            P pa = que.top();
            que.pop();
            int u = pa.se;
            if(dist[u] >= 0 && dist[u] < pa.fi)continue;
            dist[u]=pa.fi;
            for(P e : v[u]){
                if(dist[e.fi] < 0 || dist[e.fi] > dist[u] + e.se){
                    dist[e.fi] = dist[u] + e.se;
                    prever[e.fi] = u;
                    que.push(P(dist[e.fi],e.fi));
                }
            }
        }
        return dist;
    }
    void dfs(ll now, ll prv, ll c){
        d(dist[now])
        d(now)
        d(c)
        d(prv)
        dist[now]=c;
        for(auto nxt : v[now])if(nxt.fi != prv){
            d(nxt.se)
            d(prv)
            d(nxt.se % 2)
            d(nxt.fi)
            if(nxt.se % 2)dfs(nxt.fi, now, !c);
            else{d("debug")dfs(nxt.fi, now, c);}
        }
    }
    void gprint(){
        rep(i,V){ps(i);ps(": ");for(P x : v[i]){ps(x.fi);ps(",");ps(x.se);ps(" ");}p("");}
    }
 
};



int main(){
    cin>>n;
    graph G(n);
    rep(i,n-1){
        cin>>a>>b>>c;
        a--;b--;
        G.add_diedge(a,b,c);
    }
    //G.gprint();
    G.dfs(0,-1,0);
    rep(i,n)p(G.dist[i]);
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct name
{
	int value;
	struct name* next;
	int isodd;
}p_list;

int main()
{
	int n,i,j,m=0;//m:evenpath.size
	int u,v,w,startnode=100010;
	//path evenpath[100010];
	p_list* narr[100010]={(p_list *)0};//関係を持つノードの配列
	int nsizarr[100010]={0};
	int ans[100010]={0};
	scanf("%d",&n);
	for(i=0;i<n-1;i++)
	{
		scanf("%d %d %d",&u,&v,&w);
		
		p_list* lp=(p_list *)calloc(1,sizeof(p_list));
		lp->next=narr[u];
		narr[u]=lp;
		lp->value=v;
		lp->isodd=w%2;
		
		lp=(p_list *)calloc(1,sizeof(p_list));
		lp->next=narr[v];
		narr[v]=lp;
		lp->value=u;
		lp->isodd=w%2;
		
		if(u<startnode)startnode=u;
	}
	
	int treenodes[100010]={0};
	int nextnodes[100010]={0};
	treenodes[0]=startnode;
	ans[startnode]=1;
	int treesize=1;
	int nextsize=1;
	while(nextsize!=0)
	{
		nextsize=0;
		for(i=0;i<treesize;i++)
		{
			//j=0;
			//printf("a: %d\n",narr[treenodes[0]][0]);
			while(narr[treenodes[i]]!=NULL)
			{
				int prevnum=treenodes[i];
				int nextcnd=narr[treenodes[i]]->value;
				//printf("from:%d\n",prevnum);
				//printf("to:%d\n",nextcnd);
				
				if(ans[nextcnd]==0)//まだnextcndが未探索(木に加えられていない)なら
				{
					//printf("add: %d\n",nextcnd);
					if(narr[prevnum]->isodd)
					{
						nextnodes[nextsize]=nextcnd;
						nextsize++;
					}
					else
					{
						treenodes[treesize]=nextcnd;
						treesize++;
					}
				}
				if(narr[prevnum]->isodd)ans[nextcnd]=ans[prevnum]+1;
				else ans[nextcnd]=ans[prevnum];
				//j++;
				narr[prevnum]=narr[prevnum]->next;
			}
		}
		memcpy(treenodes,nextnodes,sizeof(nextnodes));
		treesize=nextsize;
			//printf("go next\n");
	}
	
	for(i=0;i<n;i++)
	{
		printf("%d\n",ans[i+1]%2);
	}
	
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

typedef struct {
  long color;
	long connected;
} S_VERTICE;

int main(void) {

  long n;
  scanf("%ld", &n);
  long **tree;
  tree = (long **)malloc(sizeof (long*) * (n+1));
  for (long i = 0; i < n+1; i++) {
    tree[i] = (long *)malloc(sizeof (long) * (n+1));
    tree[i][0] = 0;
  }
  for (long i = 1; i <= n; i++) {
    tree[0][i] = 0;
  }
	long **length;
	length = (long **)malloc(sizeof (long*) * (n+1));
  for (long i = 0; i < n+1; i++) {
    length[i] = (long *)malloc(sizeof (long) * (n+1));
  }
  long u,v,w;
  for (long i = 0; i < n-1; i++) {
    scanf("%ld %ld %ld", &u, &v, &w);
    tree[u][0]++;
    tree[u][tree[u][0]] = v;
		length[u][tree[u][0]] = w%2;
    tree[v][0]++;
    tree[v][tree[v][0]] = u;
		length[v][tree[v][0]] = w%2;
  }
  S_VERTICE vertices[n+1];
  for (long i = 1; i <= n; i++) {
    vertices[i].color = 0;
    vertices[i].connected = 0;
  }
	vertices[1].color = -1;

  long cur = 1;
	long next;
  while (1) {
    tree[0][cur]++;
    if (tree[0][cur] <= tree[cur][0]) {
			next = tree[cur][tree[0][cur]];
			if (next == vertices[cur].connected) {
	      continue;
	    }
			if (length[cur][tree[0][cur]] == 0) {
				vertices[next].color = vertices[cur].color;
			} else {
				vertices[next].color = vertices[cur].color*(-1);
			}
			vertices[next].connected = cur;
			cur = next;
    } else {
      if (cur == 1) {
        break;
      }
      cur = vertices[cur].connected;
    }
  }

	free(tree);
	free(length);

  for (long i = 1; i <= n; i++) {
		if (vertices[i].color == -1) {
			printf("0\n");
		} else {
			printf("1\n");
		}
  }

  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

typedef struct node {
    bool checked;
    int num;
    int mem;
    int dis[100000];
    struct node *next[100000];
} Node;

Node *init_node(int i) {
    Node *a = (Node *)malloc(sizeof(Node));
    a->checked = 0;
    a->num = i;
    a->mem = 0;
    return a;
}

void coloring(Node *start, int *color, int dis_0) {
    if (start->checked == 1) return;
    start->checked = 1;
    int nmem = start->mem;
    for (int i=0; i<nmem; i++) {
        Node *buf = start->next[i];
        if (buf->checked == 1) continue;
        int distan = (dis_0 + start->dis[i]) % 2;
        color[buf->num] = distan;
        coloring(buf, color, distan);
    }
}

int main() {
    int n = 0;
    scanf("%d\n", &n);
    Node *lis[n];
    for (int i=0; i<n; i++) {
        lis[i] = init_node(i);
    }
    int u = 0, v = 0;
    int mem_u = 0, mem_v = 0;
    long int w = 0;
    for (int i=0; i<n-1; i++) {
        scanf("%d %d %ld", &u, &v, &w);
        u--;
        v--;
        mem_u = lis[u]->mem;
        mem_v = lis[v]->mem;
        lis[u]->dis[mem_u] = w%2;
        lis[v]->dis[mem_v] = w%2;
        lis[u]->next[mem_u] = lis[v];
        lis[v]->next[mem_v] = lis[u];
        lis[u]->mem++;
        lis[v]->mem++;
    }
    int color[n];
    color[0] = 0;
    coloring(lis[0], color, 0);
    for (int i=0; i<n; i++) {
        printf("%d\n", color[i]);
    }
    return 0;
}
//  [javascript]
var lines = [];
var ans; var G;

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]); ans = Array(N).fill(0);
    lines.shift();

    G = Array(N).fill(0).map(i => i = [])
    for (var i = 0; i < N - 1; i++) {
        var t = lines[i].split(" ");
        var u = Number(t[0]); var v = Number(t[1]); var w = Number(t[2]);
        G[u - 1].push([v - 1, w]); G[v - 1].push([u - 1, w])
    }
    bfs(0, -1, 1)
    for (var i = 0; i < N; i++) { console.log(ans[i]); }
});

// vをcで塗る pはvの親
function bfs(v, p, c) {
    var q = [[v, p, c]]

    while (q.length) {
        var t = q.shift(); var v = t[0]; var p = t[1]; var c = t[2];
        ans[v] = c;

        for (var value of G[v]) {
            // 親は探索済み
            if (value[0] === p) { continue; }
            // 辺の距離が奇数なら
            if (value[1] & 1) { q.push([value[0], v, 1 - c]) }
            // 辺の距離が偶数なら
            else { q.push([value[0], v, c]) }
        }
    }
}
//  [javascript]
"use strict";
function I(t,i){this._s=t.split("\n"),this._c=0,this._l=0,this._f=i||Number}I.prototype.a=function(t){var i=this._s[this._l];if(i){var s=i.trim().split(" "),h=s[this._c];return this._c++,s.length===this._c&&(this._c=0,this._l++),t?t(h):this._f(h)}},I.prototype.l=function(t){var i=this._s[this._l];if(i)return this._c=0,this._l++,i.split(" ").map(t||this._f)},module.exports=I;
function Queue(e){this._queue=e?e.slice():[],this._tail=this._queue.length,this._head=0,this._maxLength=1000000000}Queue.prototype.enqueue=function(e){this._tail+1===this._head||0===this._head&&this._tail===this._maxLength-1?console.error("===queue overflow==="):(this._queue[this._tail]=e,this._tail+=1,this._tail===this._maxLength&&(this._tail=0))},Queue.prototype.dequeue=function(){if(this._tail!==this._head){var e=this._queue[this._head];return this._head+=1,this._head===this._maxLength&&(this._head=0),e}console.error("===queue underflow===")},Queue.prototype.size=function(){var e=this._tail-this._head;return e<0&&(e+=this._maxLength),e};

function main(input) {
  var o = new I(input);

  var n = o.a();
  var u = [];
  var v = [];
  var w = [];

  for (var i = 0; i < n - 1; i++) {
    u.push(o.a());
    v.push(o.a());
    w.push(o.a());
  }

  var adj = [];
  for (var i = 1; i <= n; i++) {
    adj[i] = [];
  }

  for (var i = 0; i < n - 1; i++) {
    adj[u[i]].push({
      v: v[i],
      w: w[i]
    });
    adj[v[i]].push({
      v: u[i],
      w: w[i]
    });
  }

  // console.log(adj);
  var queue = new Queue();
  var color = [, 0];
  queue.enqueue(1);
  while (queue.size() > 0) {
    var cur = queue.dequeue();
    // console.log(queue, color, {cur, adj: adj[cur]});
    adj[cur].forEach(x => {
      var v = x.v;
      if (color[v] === undefined) {
        var w = x.w;
        if (w % 2 === 0) {
          color[v] = color[cur];
        } else {
          color[v] = (color[cur] + 1) % 2;
        }
        queue.enqueue(v);
      }
    })
  }

  for (var i = 1; i <= n; i++) {
    console.log(color[i]);
  }
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";var n=r(2);r(3)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(4),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(0);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";var n=r(0);t.exports=function(t){for(var e=t.in(),r=new Array(e),i=0;i<e;i++)r[i]=[];for(var s=0;s<e-1;s++){var o=t.in()-1,u=t.in()-1,c=t.in();r[o].push({v:u,c:c}),r[u].push({v:o,c:c})}var a=new Array(e).fill(-1);a[0]=0;var f=new n;for(f.enq(0);f.size>0;)for(var l=f.deq(),p=r[l].length,v=0;v<p;v++){var d=r[l][v];-1==a[d.v]&&(a[d.v]=a[l]+d.c,f.enq(d.v))}for(var h=0;h<e;h++)console.log(a[h]%2?0:1)}}]);
//  [go]
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	edges := make(map[int]map[int]int)
	for i := 0; i < n; i++ {
		edges[i] = make(map[int]int)
	}

	for i := 0; i < n-1; i++ {
		var u, v, w int
		fmt.Scan(&u, &v, &w)
		u--
		v--
		edges[u][v] = w
		edges[v][u] = w
	}

	weights := make([]int, n)
	for i := 0; i < n; i++ {
		weights[i] = -1
	}

	q := make([]int, 0)
	q = append(q, 0)
	weights[0] = 0

	for len(q) > 0 {
		v := q[0]
		q = q[1:]

		e := edges[v]
		for u, w := range e {
			if weights[u] != -1 {
				continue
			}
			weights[u] = weights[v] + w
			q = append(q, u)
		}
	}

	for i := 0; i < n; i++ {
		fmt.Println(weights[i] % 2)
	}
}
//  [go]
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	edges := make(map[int]map[int]int)
	for i := 0; i < n; i++ {
		edges[i] = make(map[int]int)
	}

	for i := 0; i < n-1; i++ {
		var u, v, w int
		fmt.Scan(&u, &v, &w)
		u--
		v--
		edges[u][v] = w
		edges[v][u] = w
	}

	costs := calc(n, edges)
	for i := 0; i < n; i++ {
		fmt.Println(costs[i] % 2)
	}
}

func calc(n int, edges map[int]map[int]int) []int {
	costs := make([]int, n)

	var dfs func(i, p int)
	dfs = func(v, p int) {
		e := edges[v]
		for u, w := range e {
			if u == p {
				continue
			}
			costs[u] = costs[v] + w
			dfs(u, v)
		}
	}
	dfs(0, -1)

	return costs
}
//  [ruby]
##stack level too deep を疑ってみる。
##https://qiita.com/cielavenir/items/764ee9eb24b1cb43e588
##https://arc045.contest.atcoder.jp/submissions/526902

if !ENV['RUBY_THREAD_VM_STACK_SIZE']
	#require 'rbconfig';RUBY=File.join(RbConfig::CONFIG['bindir'],RbConfig::CONFIG['ruby_install_name'])
	require 'rubygems';RUBY=Gem.ruby
	exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},RUBY,$0)
end

##ここまでコピペ

N = gets.to_i
@h = {}
@res = [nil, 0]

def f(i)
	@h[i].each do |x|
		next if !@res[x[0]].nil?
		@res[x[0]] = (@res[i] ^ x[1])&1
		f(x[0])
	end
end

a = $<.read.split.map(&:to_i).each_slice(3).flat_map { |u, v, w| [u, v, w, v, u, w] }
	.each_slice(3).map { |u, v, w| [u, [v, w]] }.sort

while a.size > 0 do
	k = a.bsearch_index { |x| a[0][0] < x[0] } || a.size
	@h[a[0][0]] = a[0,k].map(&:pop)
	a.shift(k)
end

f(1)
@res.shift
puts @res
//  [ruby]
if !ENV['RUBY_THREAD_VM_STACK_SIZE']
    exec({'RUBY_THREAD_VM_STACK_SIZE'=>'1000000000'}, '/usr/bin/ruby', $0)
end


def dfs(i, l=0)
    return if @used[i]
    @used[i] = true
    @g[i].each do |j|
        #a, b = i, j
        #a, b = b, a if a > b
        dfs(j, l ^ @path[[i, j]])
    end
    @ans[i] = l
end

N=gets.to_i
UVW=(N-1).times.map{gets.split.map(&:to_i)}

@g=Array.new(N){[]}
@path=Hash.new(0)
UVW.each do |u,v,w|
    u -= 1
    v -= 1
    @g[u] << v
    @g[v] << u
    #u, v = v, u if u > v
    @path[[u, v]] = w % 2
    @path[[v, u]] = w % 2
end

@used=Array.new(N, false)
@ans=Array.new(N, 0)
dfs(0)
puts @ans
//  [ruby]
n = gets.to_i

class Node
  def initialize(index)
    @index = index
    @color = nil
    @connects = []
    @processed = false
  end

  def connect(node, w)
    @connects << {:node => node, :same => w % 2 == 0}
  end

  def connects
    return @connects
  end

  def color
    return @color
  end

  def set_color(color)
    @color = color
  end

  def processed
    @processed = true
  end

  def processed?
    return @processed
  end
end

nodes = Array.new(n) do |i|
  Node.new(i)
end

(n - 1).times do |i|
  u, v, w = gets.split.map(&:to_i)
  nodes[u - 1].connect(nodes[v - 1], w)
  nodes[v - 1].connect(nodes[u - 1], w)
end

nodes[0].set_color(0)
q = [nodes[0]]
while true
  t = q.shift
  break if t == nil
  next if t.processed?
  if t.color == nil
    q.push(t)
    next
  end
  t.processed

  t.connects.each do |c|
    if c[:same]
      c[:node].set_color(t.color)
    else
      c[:node].set_color((t.color + 1) % 2)
    end
    q.push(c[:node])
  end
end

nodes.each do |node|
  puts node.color
end
//  [rust]
use std::vec::Vec;
use std::collections::VecDeque;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


fn bfs(n: usize, root: usize, to: &Vec<Vec<(usize, i64)>>) -> Vec<i64> {
  // n is number of node
  // root is start node
  // res is legth of root
  let mut res = vec![-1; n];

  let mut q: VecDeque<usize> = VecDeque::new();
  q.push_back(root);
  res[root] = 0;

  while !q.is_empty() {
    let a: usize = match q.pop_front() {
      Some(i) => i,
      None => 1,
    };
    for &(i, w) in &to[a] {
      if res[i] != -1 {
        continue;
      }
      else {
        res[i] = (res[a] + w) % 2;
        q.push_back(i);
      }
    }
  }
  return res;
}


fn main() {
    let n: usize = read();
    let mut to: Vec<Vec<(usize, i64)>> = vec![Vec::new(); n];
    for _ in 0..n-1 {
      let a: Vec<usize> = read_vec();
      to[a[0] - 1].push((a[1] - 1, a[2] as i64));
      to[a[1] - 1].push((a[0] - 1, a[2] as i64));
    }
    let v: Vec<i64> = bfs(n, 0, &to);

    for e in v {
      println!("{}", e);
    }

}
//  [rust]
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut edges = HashMap::<usize, HashMap<usize, u64>>::new();
    let mut simple_edges = vec![Vec::new(); n];
    for _ in 0..n - 1 {
        let v = read_vec::<u64>();
        let a = v[0] as usize - 1;
        let b = v[1] as usize - 1;
        edges.entry(a).or_insert(HashMap::new()).insert(b, v[2]);
        edges.entry(b).or_insert(HashMap::new()).insert(a, v[2]);
        simple_edges[a].push(b);
        simple_edges[b].push(a);
    }
    let root = 0;
    let mut tree: Vec<Vec<usize>> = vec![Vec::new(); n];
    let mut parent_dict: HashMap<usize, usize> = HashMap::new();
    make_tree(root, n, &simple_edges, &mut tree, &mut parent_dict);
    let mut topological_sorted_indexes = vec![root];
    topological_dfs(root, &tree, &mut topological_sorted_indexes);

    let mut color = vec![2; n]; // 0: white, 1: black, 2: uncolored;
    color[0] = 0;
    for &idx in topological_sorted_indexes.iter() {
        if idx == 0 {
            continue;
        }
        let parent = parent_dict[&idx];
        assert!(color[parent] != 2);
        let dist = edges[&parent][&idx];

        if dist % 2 == 0 {
            color[idx] = color[parent];
        } else {
            color[idx] = 1 - color[parent];
        }
    }
    for i in 0..n {
        println!("{:?}", color[i]);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn topological_dfs(cur_idx: usize, tree: &Vec<Vec<usize>>, result: &mut Vec<usize>) {
    for child_idx in tree[cur_idx].iter() {
        result.push(*child_idx);
        topological_dfs(*child_idx, tree, result);
    }
}

fn make_tree(
    cur_idx: usize,
    parent_idx: usize,
    edges: &Vec<Vec<usize>>,
    tree: &mut Vec<Vec<usize>>,
    parent_dict: &mut HashMap<usize, usize>,
) {
    for child_idx in edges[cur_idx].iter() {
        if *child_idx == parent_idx {
            continue;
        }
        tree[cur_idx].push(*child_idx);
        parent_dict.insert(*child_idx, cur_idx);
        make_tree(*child_idx, cur_idx, edges, tree, parent_dict);
    }
}
//  [rust]
// #[warn(dead_code)]
// const TOP: u64 = 1000000007;

fn main() {
	let text = {
		use std::io::Read;
		let mut s = String::new();
		std::io::stdin().read_to_string(&mut s).unwrap();
		s
	};

	let mut iter = text.split_whitespace();
	let num: usize = iter.next().unwrap().parse().unwrap();

	use std::collections::HashMap;

	let mut map: HashMap<u64, HashMap<u64, u32>> = HashMap::new();

	for _ in 1..num {
		let u: u64 = iter.next().unwrap().parse().unwrap();
		let v: u64 = iter.next().unwrap().parse().unwrap();
		let w: u32 = iter.next().unwrap().parse().unwrap();
		// let u = u - 1;
		// let v = v - 1;
		map.entry(u).or_insert(HashMap::new());
		map.entry(v).or_insert(HashMap::new());
		if let Some(tmp) = map.get_mut(&u) {
			tmp.insert(v, w);
		}
		if let Some(tmp) = map.get_mut(&v) {
			tmp.insert(u, w);
		}
	}

	let mut colors: HashMap<u64, u32> = HashMap::new();
	colors.insert(1, 0);

	fn set_color(u: u64, map: &HashMap<u64, HashMap<u64, u32>>, colors: &mut HashMap<u64, u32>) {
		if let Some(tmp) = map.get(&u) {
			for (&v, &w) in tmp.iter() {
				let f: u64;
				let nc: u32;
				if let Some(&c) = colors.get(&u) {
					f = v;
					nc = if w % 2 == 1 { c ^ 1 } else { c };
				} else if let Some(&c) = colors.get(&v) {
					f = u;
					nc = if w % 2 == 1 { c ^ 1 } else { c };
				} else {
					continue;
				}
				if let None = colors.get(&f) {
					// println!("{} {}", f, nc);
					colors.insert(f, nc);
					set_color(f, map, colors);
				}
			}
		}
	}

	set_color(1, &map, &mut colors);

	for i in 1..(num + 1) {
		let i = i as u64;
		if let Some(c) = colors.get(&i) {
			println!("{}", c);
		} else {
			continue;
		}
	}
}
//  [typescript]
const log = console.log;

const createScanFunctions = (input: string) => {
  const str = input.trim();
  const len = str.length;
  let index = 0;

  const scan = () => {
    const startIndex = index;

    while (index < len) {
      const char = str[index];

      if (char === " " || char === "\n")
        return str.substring(startIndex, index++);

      index++;
    }

    return str.substr(startIndex);
  };

  const scanInt = () => parseInt(scan());

  return { scan, scanInt };
};

const createArrayOfNumberArrays = (length: number) => {
  const array = new Array<number[]>(length);
  for (let i = 0; i < length; i++) array[i] = [];

  return array;
};

const isEven = (n: number) => (n & 1) === 0;

// ----

function Main(input: string): void {
  const { scanInt } = createScanFunctions(input);

  // prepare graph
  const n = scanInt();
  const neighborIdTable = createArrayOfNumberArrays(n);
  const neighborDistanceTable = createArrayOfNumberArrays(n);
  const vertexColorArray = new Array<number | undefined>(n).fill(undefined);

  function linkVertices(id: number, neighborId: number, distance: number) {
    neighborIdTable[id].push(neighborId);
    neighborDistanceTable[id].push(distance);
    neighborIdTable[neighborId].push(id);
    neighborDistanceTable[neighborId].push(distance);
  }

  // read edges data
  const edgeCount = n - 1;

  for (let i = 0; i < edgeCount; i++)
    linkVertices(scanInt() - 1, scanInt() - 1, scanInt());

  // prepare search, visit first vertex
  const recentVisitedStack: number[] = [];

  vertexColorArray[0] = 0;
  recentVisitedStack.push(0);

  const visitVertices = (recentVisitedStack: number[]) => {
    const recentVertexId = recentVisitedStack.pop() as number; // checked before calling this function

    const neighborIdArray = neighborIdTable[recentVertexId];
    const neighborDistanceArray = neighborDistanceTable[recentVertexId];
    const neighborCount = neighborIdArray.length;
    const recentColor = vertexColorArray[recentVertexId] as number; // unsafe

    for (let i = 0; i < neighborCount; i++) {
      const neighborId = neighborIdArray[i];

      if (vertexColorArray[neighborId] !== undefined) continue; // already visited

      vertexColorArray[neighborId] = isEven(neighborDistanceArray[i])
        ? recentColor
        : recentColor ^ 1;

      recentVisitedStack.push(neighborId);
    }
  };

  // search & paint
  while (recentVisitedStack.length > 0) visitVertices(recentVisitedStack);

  // output
  for (const color of vertexColorArray) log(color);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
import numpy as np
N,K,Q = map(int,input().split())
P = np.array(N*[K])

for q in range(Q):
  a = int(input())
  P[a-1]+=1
  P-=1

for n in range(N):
  if P[n]<=0:
    print("No")
  else:
    print("Yes")
//  [python]
n,k,q,*a=map(int,open(0).read().split())
import numpy as np
points=np.full(n,k)

for i in range(q):
    points-=1
    points[a[i]-1]+=1

for i in range(n):
    print('NYoe s'[points[i]>0::2])
//  [python]
import numpy as np
N, K, Q = map(int, input().split())
A = []
for i in range(Q):
  a = int(input())
  A.append(a)
participant = [] 
for i in range(N):
  participant.append(K)
participant_arr = np.array(participant) 
for i in range(Q):
  participant_arr -= 1
  participant_arr[A[i] - 1] += 1
for i in range(N):
  if participant_arr[i] > 0:
    print("Yes")
  else:
    print("No")
//  [java]
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        sc.nextLine();
        List<Integer> list = new ArrayList<>();
        for (int i=0;i<q;i++) {
            list.add(sc.nextInt());
            sc.nextLine();
        }
        Map<Integer, Long> map = list.stream().collect(Collectors.groupingBy(m -> m, Collectors.counting()));
        for (int i = 1; i<=n; i++) {
            if (q - map.getOrDefault(i, (long) 0) < k) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}