text justification and dfs with memozation