I expect the answer (if there is one) will be more complicated than the question, which is
I would like to have 2 input wires and 1 output wire.
One input wire comes from the frog and the second comes from one side of the track. If they are the same, then the output wire will also be live, if not then there is no power to the output.