Solution
C++ []\nclass Solution {\npublic:\n    vector<string> ambiguousCoordinates(string s) {\n        string cur1 = "";\n        string cur2 = "";\n        vector<str
```C++ []\nclass Solution {\npublic:\n    vector<string> ambiguousCoordinates(string s) {\n        string cur1 = "";\n        string cur2 = "";\n        vector<string> res;\n        bool confirmedFirstPart = false;\n        bool usedDot = false;\n        backtrack(s, cur1, cur2, res, 0, confirmedFirstPart, usedDot);\n        return res;\n    }\n    void backtrack(string& s, string& cur1, string& cur2, vector<string>& res, int index, bool& confirmedFirstPart, bool& usedDot)\n    {\n        if (index == s.length())\n        {\n            if (confirmedFirstPart == true)\n            {\n                if (cur2.size() != 2 && (cur2[cur2.size() - 2] == \'0\') && (cur2[0] == \'0\')) return;\n                res.push_back(cur1 + cur2);\n            }\n            return;\n        }\n        if (s[index] != \'(\' && s[index] != \')\')\n        {\n            if (usedDot == false && index != s.length() - 2)\n            {\n                if (!confirmedFirstPart)\n                {\n                    cur1.push_back(s[index]);\n                    cur1.push_back(\'.\');\n                    usedDot = true;\n                    backtrack(s, cur1, cur2, res, index + 1, confirmedFirstPart, usedDot);\n                    cur1.pop_back();\n                    cur1.pop_back();\n                    usedDot = false;\n                }\n                else\n                {\n                    cur2.push_back(s[index]);\n                    cur2.push_back(\'.\');\n                    usedDot = true;\n                    backtrack(s, cur1, cur2, res, index + 1, confirmedFirstPart, usedDot);\n                    cur2.pop_back();\n                    cur2.pop_back();\n                    usedDot = false;\n                }\n            }\n            if (confirmedFirstPart == false && index != s.length() - 2)\n            {\n                if (!(usedDot == true && s[index] == \'0\'))\n                {\n                    cur1.push_back(s[index]);\n                    cur1.push_back(\',\');\n                    cur1.push_back(\' \');\n                    confirmedFirstPart = true;\n                    bool usedDotCopy = usedDot;\n                    usedDot = false;\n                    backtrack(s, cur1, cur2, res, index + 1, confirmedFirstPart, usedDot);\n                    cur1.pop_back();\n                    cur1.pop_back();\n                    cur1.pop_back();\n                    confirmedFirstPart = false;\n                    usedDot = usedDotCopy;\n                }\n            }\n            if (!confirmedFirstPart) \n            {\n                if (!(cur1.size() == 1 && s[index] == \'0\'))\n                {\n                    cur1.push_back(s[index]);\n                    backtrack(s, cur1, cur2, res, index + 1, confirmedFirstPart, usedDot);\n                    cur1.pop_back();\n                }\n            }\n            else\n            {\n                if (!(cur2.empty() && index != s.length() - 2 && s[index] == \'0\') && \n                    !(usedDot && index == s.length() - 2 && s[index] == \'0\'))\n                {\n                    cur2.push_back(s[index]);\n                    backtrack(s, cur1, cur2, res, index + 1, confirmedFirstPart, usedDot);\n                    cur2.pop_back();\n                }\n            }\n        }\n        else\n        {\n            if (s[index] == \'(\')\n            {\n                cur1.push_back(\'(\');\n                backtrack(s, cur1, cur2, res, index + 1, confirmedFirstPart, usedDot);\n                cur1.pop_back();\n            }\n            else\n            {\n                cur2.push_back(\')\');\n                backtrack(s, cur1, cur2, res, index + 1, confirmedFirstPart, usedDot);\n                cur2.pop_back();\n            }\n        }\n    }\n};\n```\n\n```Python3 []\nclass Solution:\n    def gen_nums(self, s):\n        ans = []\n        if s == "0" or s[0] != "0":\n            ans.append(s)\n        \n        if s[-1] == \'0\':\n            return ans\n        \n        if s[0] == \'0\':\n            return ans + [\'0.\' + s[1:]]\n\n        for i in range(1, len(s)):\n            ans.append(s[:i] + \'.\' + s[i:])\n        return ans\n\n    def ambiguousCoordinates(self, s: str) -> List[str]:\n        s = s[1:-1]\n        res = []\n        for left_len in range(1, len(s)):\n            l = self.gen_nums(s[:left_len])\n            r = self.gen_nums(s[left_len:])\n            for n1 in l:\n                for n2 in r:\n                    res.append(f\'({n1}, {n2})\')\n                    \n        return res\n```\n\n```Java []\nclass Solution {\n    public List<String> helper (String s) {\n        List<String> answer = new ArrayList<> ();\n        if (s.length () == 1) {\n            answer.add (s);\n            return answer;\n        }\n        else if (s.charAt (0) == \'0\' && s.charAt (s.length () - 1) == \'0\') {\n            return answer;\n        }\n        else if (s.charAt (0) == \'0\') {\n            StringBuilder sb = new StringBuilder ();\n            sb.append (s.charAt (0)).append (".").append (s.substring (1));\n            answer.add (sb.toString ());\n            return answer;\n        }\n        else if (s.charAt (s.length () - 1) == \'0\') {\n            answer.add (s);\n            return answer;\n        }\n        answer.add (s);\n        for (int i = 1; i < s.length (); i++) {\n            StringBuilder sb = new StringBuilder ();\n            sb.append (s.substring (0, i)).append (".").append (s.substring (i));\n            answer.add (sb.toString ());\n        }\n        return answer;\n    }\n    public List<String> ambiguousCoordinates(String s) {   \n        List<String> answer = new ArrayList<> ();\n        for (int i = 2; i < s.length () - 1; i++) {\n            List<String> leftLists = helper (s.substring (1, i));\n            List<String> rightLists = helper (s.substring (i, s.length () - 1));\n            \n            for (String leftString : leftLists) {\n                for (String rightString : rightLists) {\n                    StringBuilder sb = new StringBuilder ();\n                    sb.append ("(").append (leftString).append (", ").append (rightString).append (")");\n                    answer.add (sb.toString ());\n                }\n            }\n        }\n        return answer;\n    }\n}\n```\n
['C++', 'Java', 'Python3']