Code to find and check for universal ternary gates.