What you need to do is break the whole problem you have here in to smaller more manageable problems.
There are two main portions to your particular assignment which are the matrix calculations on arbitrarily sized matrices and parsing the input file. There is then the third much simpler task of writing your results to another file.
So, parsing the input file can be broken down into a few much simpler problems again that you should be able to figure out by some light searching.
1. Open a file
2. Read lines from the file
3. parse each line to get the data you need
3a. Line 1, Change string into int to get number of matrices in file
3b. Line 2, split the string into two so you have a separate string for each number, then convert each string into an int to find out the size of the matrix
3c. Parse Y lines and split into X number of ints to get the matrix data
Etc.
I think you get the idea there. Reading and writing from files is fairly easy to do so you shouldn't have much trouble finding information on that and you should be able to find numerous articles on working with n*n matrices, it might be worth trying to search for C++ articles on the subject so you don't get to bogged down with all the fancy symbols that mathematicians like to use (They get me confused anyway).
As this is an assignment we can't simply give you the solution but if you have any specific problems or bugs that you can't work out you can always post another question about it.