Fixed problem in ext-gcd solution; Provided bfs solution