matrix to compute the ways on giving all the different