Understanding test case for locked-in-gear puzzle


Can somebody explain output of the test case 5? How can it be “NOT MOVING”? I am stuck at this test case.


Did you try drawing it?



I got also stuck. But after drawing I figured out that my problem was that I stopped my BFS when finding the last one in the initial inputs which was wrong because you need to check if something breaks further down the line.