Simple C++ solution
\nclass Solution {\npublic:\n    bool check(string s, bool issecword){\n        int n=s.length();\n\t\t// Logic explained above\n        if(issecword){\n       
```\nclass Solution {\npublic:\n    bool check(string s, bool issecword){\n        int n=s.length();\n\t\t// Logic explained above\n        if(issecword){\n            if(n>0 && s[n-1]==\'0\') return false;\n        }\n        else{\n            if(n>1 && s[0]==\'0\') return false;\n        }\n        return true;\n    }\n\n    vector<string> ambiguousCoordinates(string S) {\n        vector<string> res;\n        S=S.substr(1,S.length()-2);\n        int n=S.length();\n\n        for(int i=1;i<n;i++){\n            string s1=S.substr(0,i);\n            string s2=S.substr(i);\n            vector<string> res1, res2;\n\t\t\t\n            if(check(s1, false)) res1.push_back(s1);\n            if(check(s2, false)) res2.push_back(s2);\n\t\t\t\n            for(int j=1;j<s1.length();j++){\n                string first=s1.substr(0,j);\n                string second=s1.substr(j);\n                if(check(first, false) && check(second, true)) res1.push_back(first+"."+second);\n            }\n            \n            for(int j=1;j<s2.length();j++){\n                string first=s2.substr(0,j);\n                string second=s2.substr(j);\n                if(check(first, false) && check(second, true)) res2.push_back(first+"."+second);\n            }\n\t\t\t\n            for(auto left:res1){\n                for(auto right:res2){\n                    res.push_back("(" + left + ", "+ right + ")");\n                }\n            }\n        }\n        return res;\n    }\n};\n```
[]