The Brazilian government will relocate the inmates responsible for a bloody riot in a prison in the northern Amazon city of Manaus to high security federal institutions, and will prosecute them.

Justice minister, Alexandre de Moraes said on Tuesday that authorities would move quickly to identify and transfer the gang bosses out of the crowded jail in the remote jungle state of Amazonas where the fighting between rival drug gangs left 56 dead on Sunday.

The riot lasted for 17 hours in the Anisio Jobim complex in Manaus, the capital of Amazonas state. Many of those slain were beheaded or dismembered in the worst bloodshed at a Brazilian prison since 1992.

The killings occurred over a feud between rival criminal factions, the Sao Paulo-based First Capital Command (PCC) and a local Amazonian crime group Family of the North (FDN), who are engaged in a long-term dispute over controlling prisons, drug trafficking routes, and territory in the region reeling from drug violence.

Machete-wielding gangs decapitated inmates and threw their bodies over a wall of the prison, which houses more than three times as many prisoners as it was built for in 1982.

Police hunted for more than 100 inmates who escaped from the prison during the riot.

"One group is trying to eliminate the other so they can dominate the prison system," said Marluce da Costa Sousa, coordinator of the Amazonas state branch of Pastoral Carceraria - a prisoner advocate group linked to the Catholic church.

"It's about profit," she told Al Jazeera on Monday.

Meanwhile on Tuesday, dozens of people stood outside the coroner's office in Manaus to find if their relatives were among the dead.

Sara Santos, 36, said she was seeking news of her 23-year-old brother, who had been in prison for drug trafficking.

"Nobody knows who is alive or dead," Santos told the Associated Press news agency.

Amazonas authorities said families would be paid a compensation for the killings of their relatives in prison.

Public security secretary Sergio Fontes said the first bodies of the victims will be handed to their families starting Tuesday evening.

With more than 600,000 inmates, Brazil has the fourth largest prison population in the world after the United States, China, and Russia, and its prisons have long been denounced by human rights groups for violence and serious overcrowding.

The riot led to the biggest number of prison deaths in Brazil since the 1992 Carandiru massacre in Sao Paulo when 111 prisoners, many unarmed, were killed - almost all by military police - when they stormed the prison following a riot.

Four inmates were found dead in another prison in the rural area of Manaus on Monday. State officials were not able to say whether there had been a riot there.