Deadly Brazil prison riot ends after agreements reached