BAD-HORSE

It's a bipartie problem, we can solve it with BFS