Simple C++ Sol { Backtracking }
\nclass Solution {\npublic:\n    int maxCompatibilitySum(vector<vector<int>>& students, vector<vector<int>>& mentors) {\n        int res = INT_MIN, n = students
```\nclass Solution {\npublic:\n    int maxCompatibilitySum(vector<vector<int>>& students, vector<vector<int>>& mentors) {\n        int res = INT_MIN, n = students.size(), m = students[0].size();\n        \n        vector<bool> visited(n, false);\n        f(0, 0,students, mentors, visited, res, n, m);\n        \n        return res;\n    }\n    \n    void f(int start, int sum, vector<vector<int> > &students, vector<vector<int>  >&mentors, vector<bool> &visited, int &res, int n, int m) {\n        if(start == n) {\n            res = max(res, sum);\n            return;\n        }\n        \n        for(int i = 0; i < n; i++) {\n            if(!visited[i]) {\n                int count = 0;\n                for(int j = 0; j < m; j++) {\n                    if(students[start][j] == mentors[i][j])\n                        count++;\n                }\n                visited[i] = true;\n                f(start+1, sum+count, students, mentors, visited, res, n, m);\n                visited[i] = false;\n            }\n        }\n    }\n};\n```
[]