Do you Not want the 5V circuit and the 12V circuit to have common ground?
In that case use an optoisolator.
LED power for the 2 otpo's can be the 12V source, don't forget current limit resistor.
Open collector/open drain output can pull the separate 10K resistors low to the 5V GND and the 12V GND.
Example:
http://www.digikey.com/product-detail/en/LTV-826/160-1362-5-ND/385832