package main import . "fmt" type Cond struct { a,b,c,p,q,r int } func (c *Cond)Scan(s ScanState, v rune) error { Fscan(s, &c.a, &c.b, &c.c, &c.p, &c.q, &c.r) c.a,c.b,c.c = 255-c.a,255-c.b,255-c.c return nil } func main() { conds := make([]*Cond, 2048) for i := range conds { conds[i] = new(Cond) Scan(conds[i]) } ans := make([]int, 256) filled := make([]bool, 256) for _, c := range conds { if filled[c.a] && ans[c.a] == c.p { continue } if filled[c.b] && ans[c.b] == c.q { continue } if filled[c.c] && ans[c.c] == c.r { continue } if !filled[c.a] { ans[c.a] = c.p filled[c.a] = true continue } if !filled[c.b] { ans[c.b] = c.q filled[c.b] = true continue } if !filled[c.c] { ans[c.c] = c.r filled[c.c] = true continue } break } for _, x := range ans { Print(x) } Println() }