Link to this code: https://cses.fi/paste/5eda5dbd61be4b0ac9db11/
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    map <char, long long> m;
    string s;
    cin>>s;
    char a;
    vector <char> v;
    long long tek=0;
    for(int i=0; i<s.size(); i++)
    {
        m[s[i]]++;
    }
    for(auto i:m)
    {
        if(i.second%2==1)
        {
            tek++;
            a=i.first;
        }
    }
    if(tek>1)
    {
        cout<<"NO SOLUTION";
        return 0;
    }
    for(auto i:m)
    {

           long long n;
           n=i.second/2;
           while(n--)
           {
               cout<<i.first;
               v.push_back(i.first);
           }
            
           
    }
   reverse(v.begin(), v.end());
   cout<<a;
   for(int i=0; i<v.size(); i++)
   {
       cout<<v[i];
   }
   cout<<endl;
    
}