DFS. I think the code is clean, but I forgot to backtrack at first...