Two councils exposed 350 children to repeated rapes and abuse for more than five decades, an inquiry finds.