Python3. Straightforward top down dp
\nclass Solution:\n    def maxCompatibilitySum(self, students: List[List[int]], mentors: List[List[int]]) -> int:\n        pair_score = defaultdict(int)\n      
```\nclass Solution:\n    def maxCompatibilitySum(self, students: List[List[int]], mentors: List[List[int]]) -> int:\n        pair_score = defaultdict(int)\n        n = len(students)\n\n        # build compatibilty score for every possible student-mentor pair\n        for i in range(n):\n            for j in range(n):\n                pair_score[i, j] = sum(s_ans == m_ans for s_ans, m_ans in zip(students[i], mentors[j]))\n        \n        # try to pair student[i] with every unused mentor\n        # mentor[j] is unused if \'j\'th bit in mask is \'1\'\n        @cache\n        def dfs(i, mask):\n            if i == len(students):\n                return 0\n            return max(dfs(i + 1, mask - (1 << j)) + pair_score[i, j] for j in range(n) if (1 << j) & mask)\n                    \n        return dfs(0, (1 << len(students)) - 1)\n```
[]