//{ Driver Code Starts #include using namespace std; // } Driver Code Ends /*You are required to complete this method*/ class Solution{ public: bool check(string s) { int n=s.length(); if(n<0 || n>3) { return false; } if(s[0]=='0' && n>1) { return false; } int p=stoi(s); if(p<0 || p>255 ) { return false; } return true; } string generate(string &s,int i,int j,int k,int n) { string s1=s.substr(0,i); string s2=s.substr(i,j-i); string s3=s.substr(j,k-j); string s4=s.substr(k,n-k); if(check(s1) && check(s2) && check(s3) && check(s4)) { return s1+"."+s2+"."+s3+"."+s4; } return ""; } vector genIp(string &s) { // Your code here vector ans; int n=s.length(); for(int i=1;i0) { ans.push_back(st); } } } } return ans; } }; //{ Driver Code Starts. int main() { int T; cin >> T; while (T--) { string s; cin >> s; /*generating naively*/ Solution obj; vector str = obj.genIp(s); sort(str.begin(), str.end()); if(str.size()==0) cout << -1 << "\n"; else{ for (auto &u : str) { cout << u << "\n"; } } } } // } Driver Code Ends