Java Solution
\nclass Solution {\n    public int minimumTeachings(int n, int[][] languages, int[][] friendships) {\n        int m = languages.length;\n        boolean[][] kno
```\nclass Solution {\n    public int minimumTeachings(int n, int[][] languages, int[][] friendships) {\n        int m = languages.length;\n        boolean[][] knowsLang = new boolean[m][n];\n        for(int i = 0; i < m; i++) {\n            for(int j = 0; j < languages[i].length; j++) {\n                knowsLang[i][languages[i][j]-1] = true;\n            }\n        }\n        boolean[][] canSpeak = new boolean[m][m];\n        for(int i = 1; i <= n; i++) {\n            for(int[] friendship : friendships) {\n                int x = friendship[0], y = friendship[1];\n                if(knowsLang[x-1][i-1] && knowsLang[y-1][i-1]) {\n                    canSpeak[x-1][y-1] = true;\n                }\n            }\n        }\n        int res = Integer.MAX_VALUE;\n        for(int i = 1; i <= n; i++) {\n            int numTaught = 0;\n            boolean[] iTaught = new boolean[m];\n            for(int[] friendship : friendships) {\n                int x = friendship[0], y = friendship[1];\n                if(canSpeak[x-1][y-1])  continue;\n                if(!knowsLang[x-1][i-1] && !iTaught[x-1]) {\n                    numTaught++;\n                    iTaught[x-1] = true;\n                }\n                if(!knowsLang[y-1][i-1] && !iTaught[y-1]) {\n                    numTaught++;\n                    iTaught[y-1] = true;\n                }\n            }\n            res = Math.min(numTaught, res);\n        }\n        return res;\n    }\n}\n```
[]