Optimized coloring rules, code