BFS algorithm
First/LastButtons