BFS, TLE on large input