Programmable 3-valued gates