SPOJ BUGLIFE

I am getting TLE for BFS from multiple sources(disjoint graph) and WA in case of DFS.
Can anyone help me get accepted in both the cases??