Simplify ternary