C++ solution with explanation
So, the question statement shall be paraphrased as follows:\n\nFind the minimum number of users to learn a new language L, such that for each pair of immediate 
So, the question statement shall be paraphrased as follows:\n\nFind the minimum number of users to learn a new language L, such that *for each pair of immediate friends (**no** nested relationships...), they don\'t have a common language, but each of them may or may not have learned L.*\n\n(-_-)\n\n```cpp\nclass Solution {\npublic:\n    bool ck[510];\n    std::unordered_map<int, vector<int>> F;\n    std::vector<set<int>> lv;\n    int nope[510][510];\n    \n    void inF(int k, int f) {\n        if (F.count(k) == 0) {\n            F[k] = { f };\n        }\n        else {\n            F[k].push_back(f);\n        }\n    }\n    bool valid(int f1, int f2) {\n        for (int v : lv[f1]) {\n            if (lv[f2].find(v) != lv[f2].end())\n                return true;\n        }\n        return false;\n    }\n    int minimumTeachings(int n, vector<vector<int>>& languages, vector<vector<int>>& friendships) {\n        int m = languages.size();\n        for (vector<int> f : friendships) {\n            inF(f[0], f[1]);\n            inF(f[1], f[0]);\n        }\n        lv = {};\n        for (int i = 0; i < m; i++) {\n            set<int> s = {};\n            lv.push_back(s);\n            for (int li : languages[i]) {\n                lv[i].insert(li);\n            }\n        }\n        for (int i = 0; i < 510; i++) {\n            ck[i] = false;\n            for (int j = 0; j < 510; j++) {\n                nope[i][j] = false;\n            }\n        }        \n        vector<pair<int, int>> diffF = {};\n        for (int ppl = 1; ppl <= m; ppl++) {\n            for (int pplf : F[ppl]) {\n                if (!nope[ppl][pplf]) {\n                    if (!valid(ppl - 1, pplf - 1)) {\n                        diffF.push_back({ppl - 1, pplf - 1});\n                    }\n                    nope[ppl][pplf] = true;\n                    nope[pplf][ppl] = true;\n                }\n            }\n        }\n        int rescnt = m + 1;\n        for (int l = 1; l <= n; l++) {\n            int tmpcnt = 0;\n            for (int i = 0; i < 510; i++)\n                ck[i] = false;\n            for (pair<int, int> df : diffF) {\n                if (lv[df.first].find(l) == lv[df.first].end()) {\n                    ck[df.first] = true;\n                }\n                if (lv[df.second].find(l) == lv[df.second].end()) {\n                    ck[df.second] = true;\n                }\n            }\n            for (int ppl = 0; ppl < m; ppl++) {\n                tmpcnt += ck[ppl];\n            }\n            rescnt = std::min(rescnt, tmpcnt);\n        }\n        return rescnt;\n    }\n};\n```
[]