How do I optimize my code?

bfs
tle

#1

I am trying to solve this problem : https://www.codechef.com/problems/WORDS1

I am using BFS to see if the graph is connected and then finding Eulerian path.

My code : https://www.codechef.com/viewsolution/8669072 (adjacency list)

https://www.codechef.com/viewsolution/8669050 (adjacency matrix)