Very simple c++ code with all possible combinations. Simply use of stl.
\n// As m and n are too small so that we can check every possible combination.\n// As it hard to shuffle complete so just use their indexes. And with stl functi
```\n// As m and n are too small so that we can check every possible combination.\n// As it hard to shuffle complete so just use their indexes. And with stl function permutation\n// check ans with next permutation. Continue till all permutation done.\nclass Solution {\npublic:\n    int maxCompatibilitySum(vector<vector<int>>& stud, vector<vector<int>>& ment) {\n        int r=stud.size(),c=stud[0].size(),ans=0,i=0;\n        vector<int> idx;\n        while(i<r)\n        {\n            idx.push_back(i);\n            i++;\n        }\n        do\n        {\n            int curr=0;\n            i=0;\n            while(i<r)\n            {\n                int j=0;\n                while(j<c)\n                {\n                    curr+=(stud[idx[i]][j]==ment[i][j]);\n                    j++;\n                }\n                i++;\n            }\n            ans=max(ans,curr);\n        }while(next_permutation(idx.begin(),idx.end()));\n        return ans;\n    }\n};\n```
['C']