fix blue dfs bug and implement red dfs