[Python]
\nclass Solution:\n    def maxCompatibilitySum(self, students: List[List[int]], mentors: List[List[int]]) -> int:\n        res = [-1]\n        visited = [False]
```\nclass Solution:\n    def maxCompatibilitySum(self, students: List[List[int]], mentors: List[List[int]]) -> int:\n        res = [-1]\n        visited = [False]*len(students)\n        #ssf ===> score so far\n        #res ==> final result. It is a list as it acts as a global variable\n        #idx ====> index over students array.\n        self.maxCompatibilityUtil(students,mentors,0,visited,res,0)\n        return res[0]\n    \n    \n    def maxCompatibilityUtil(self,students,mentors,ssf,visited,res,idx):\n        if idx==len(students):\n            res[0] = max(res[0],ssf)\n            return \n        \n        for i in range(len(mentors)):\n            if visited[i]==False:\n                visited[i]=True\n                temp = 0\n                for j in range(len(mentors[i])):\n                    if mentors[i][j]==students[idx][j]:\n                        temp = temp+1\n                self.maxCompatibilityUtil(students,mentors,ssf+temp,visited,res,idx+1)\n                visited[i]=False\n\t\t\t\t\n\t```\n\t\nWe have to check for every student-mentor pair. \nCan someone please tell me how to post any image? Or maybe some tool that can help me draw and post on leetcode. With Euler tree, this can be understood pretty easily.
['Backtracking', 'Recursion', 'Python', 'Python3']