word game dfs and bfs