ternary coloring