Security with multiple electric lines
You can get rid of the ac mains-powered relays for your 'sensing' side to tell the 'duino when each circuit has available power. A resistive voltage-divider with a diode &amp; cap can do the same thing with lower power dissipation and should give you a much longer lifetime.
You can use an N-MOSFET to drive output relays ok (but with limited lifetime due to physical switching stresses &amp; possible contact welding), or you could have it drive an AC-switching MOSFET pair, as in the following (simplified) diagram:



SCHEMATIC NOTES:


No overvoltage-clamping, or any other protective circuitry is shown in this diagram, but it should absolutely be used in your final project
The P-MOSFETS for the AC output stages must be specifically selected for this use. 'Normal' power MOSFETS will simply burn up their 'body diodes' in this configuration (without additional protection), rather than switching correctly.