Trinary logic puzzle to match the output by moving around gates