BFS is cool, but not for this task, because if we have big map (10^3 x 10^3), we will catch stack overflow