Solution of matrix Riemann-Hilbert problems with quasi-permutation monodromy matrices