BFS - Shortest Path why do i get tle error in this

check for this test case
1
4 3
1 2
1 3
2 4
1