Find the Blue Dog and click them! Simple, right? Click the Flag to generate a new arrangement.
I tried to remove 100% impossible states, and I made some major speed optimizations.