revisit problem M.