Use DFS to solve Problem 122.