Added the solution for the similarity matrix problem