A brawl between rival drug gangs at an overcrowded penitentiary in northern Mexico turned into a riot Thursday, leaving 49 inmates dead and 12 injured in the country’s deadliest prison melee in years.