Finally got the logic working.

Who knew? I had to draw it all out.
Then it was easy.