Dual WAN\Dual LAN

Would a config with Dual WAN links and dual LANs, lets call them A and B, X and Y respectively.

When both WAN links are up I want traffic from LAN X to use WAN A and LAN Y to use WAN B.

When WAN A is up and WAN B is down I want LAN X to use WAN A and no Internet access for LAN Y.

When WAN A is down and WAN B is up I want LAN X to use WAN B and have priority over any trafic from LANY, whcih can also use WAN B.