We will use the concept of span to make our argument concise. Read if you don’t know what a span is: https://en.wikipedia.org/wiki/Linear_span .
Firstly, an invertible matrix with modulo entries implies the image of the linear map corresponding to this matrix spans the whole vector space . Let be any basis for . Basis is the smallest linearly independent set which spans the whole vector space. We claim that for every basis their is a corresponding invertible matrix . This follows from the rank-nullity theorem, definition of matrix representation of linear transformations. Then our problem becomes to count the number of unique bases of . It is a common trick to extend an empty set to a basis for a vector space in linear algebra. The idea is that we have a basis for some subspace . We pick an element from and continue until has vectors in it. Here means contains only zero vector. Now, finally we get , where is selected at the step of extending the basis. Verify that each can be chosen in ways. Hence the final answer is . Now print this modulo .