Scale down to reduce state space. Dividing by turned states into .
Use mathematical observation to shortcut. For large , one outcome dominates, so return early.
Multiple stopping conditions need careful base cases. Both empty vs A empty vs B empty. This problem shows that probability DP often needs problem-specific tricks. Understanding the math helps. Apply these patterns when you encounter similar problems.