/**
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
Make it happen now, not tomorrow.
Tomorrow is a  loser's excuse.
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
**/
#ifndef _GLIbCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplu >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <cstring>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include<random>
#include <chrono>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplu >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#endif
#define __ ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
// #define INF 0x7f7f7f7f
#define ull unsigned long long int
#define pii pair<int,int>
#define ll long long int
#define ld long double
#define MSET(x,y) memset(x,y,sizeof(x))
// #define l long
#define se second
#define AlphaSize 26
#define fi first
#define NIL 0
#define UNVISITED -1
#define EXPOLORED 0
#define mk make_pair
#define pb push_back
#define sc(n) scanf("%d",&n)
#define NIL 0
#define db double
#define pii pair<int,int>
#define eps 1e-8
#define inrange(x,y,n,m) ((x>=1 && y>=1 && x<=n && y<=m))
#define all(x) x.begin(),x.end()
#define me(u,v,w) make_pair(w,make_pair(u,v))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define foreach(e, x) for(__typeof(x.begin()) e = x.begin(); e != x.end(); ++ e)
// #define add(a,b) (a + b >= MOD ? a+b-MOD:a+b)
#define hs(c1,c2) (256*min(c1,c2) + max(c1,c2))
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef struct{ int sum,suf,pre,max;} Node;
int toint(const string &s) { stringstream ss; ss << s; int x; ss >> x; return x; }
const int MAXN = 2e5+100;
const int UP = 31;
// const ll inf = 1e18;
// const int mod = 1e9+7;
const ll highest = 1e18;
// const int inf = 1e9+10;
// const dou    ble pi = 3.141592653589793238462643383;
const double pi = acos(-1);
const double Phi =  1.618033988749894;
const int logn = 20;
const double root5 = 2.236067977;
const ll inf = 1e18;
const int mod = 998244353;
const int ini = -1e9;
/**
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
Make it happen now, not tomorrow.
Tomorrow is a loser's excuse.
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
**/
//E.cpp
const int N = 2e5+10;
double x[N];
int n;
double l,r;
long double ans[10];
bool solve(double d){
    double range = -1e10;
    int it = 0;
    for(int i=0;i<n;++i){
        if(fabs(x[i]-range)<eps)continue;
        if(x[i]<=range)continue;
        ans[it++] = x[i] + d;
        range = max(range,x[i]+d+d);
        if(it>3)break;
    }
    return (it<=3);
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        cin>>x[i];
        // r = max(r,x[i]);
    }
    sort(x,x+n);
    n = unique(x,x+n) - x;
    l = 0;
    r = 1e9;
    for(int it=0;it<200;++it){
        double m = (l + r)/2.;
        if(solve(m)){
            r = m;
        }else{
            l = m;
        }
    }
    printf("%.7lf\n", (l+r)/2.);
    for(int i=0;i<3;++i){
        double an = min(max(0.0L,ans[i]),1E9L+100);
        printf("%.7lf ",an);
    }
    cout<<endl;
    return 0;
}
// struct bigint {
//     vector<int> z;
//     int sign;

//     bigint() :
//         sign(1) {
//     }

//     bigint(long v) {
//         *this = v;
//     }

//     bigint(const string &s) {
//         read(s);
//     }

//     void operator=(const bigint &v) {
//         sign = v.sign;
//         z = v.z;tor=(long long v) {
//         sign = 1;
//         if (v < return 0;0)
//             sign = -1, v = -v;
//         z.clear();
//         for (; v > 0; v = v / base)
//             z.push_back(v % base);
//     }

//     bigint operator+(const bigint &v) const {
//         if (sign == v.sign) {
//             bigint res = v;

//             for (int i = 0, carry = 0; i < (int) max(z.size(), v.z.size()) || carry; ++i) {
//                 if (i == (int) res.z.size())
//                     res.z.push_back(0);
//                 res.z[i] += carry + (i < (int) z.size() ? z[i] : 0);
//                 carry = res.z[i] >= base;
//                 if (carry)
//                     res.z[i] -= base;
//             }
//             return res;
//         }
//         return *this - (-v);
//     }

//     bigint operator-(const bigint &v) const {
//         if (sign == v.sign) {
//             if (abs() >= v.abs()) {
//                 bigint res = *this;
//                 for (int i = 0, carry = 0; i < (int) v.z.size() || carry; ++i) {
//                     res.z[i] -= carry + (i < (int) v.z.size() ? v.z[i] : 0);
//                     carry = res.z[i] < 0;
//                     if (carry)
//                         res.z[i] += base;
//                 }
//                 res.trim();
//                 return res;
//             }
//             return -(v - *this);
//         }
//         return *this + (-v);
//     }

//     void operator*=(int v) {
//         if (v < 0)
//             sign = -sign, v = -v;
//         for (int i = 0, carry = 0; i < (int) z.size() || carry; ++i) {
//             if (i == (int) z.size())
//                 z.push_back(0);
//             long long cur = z[i] * (long long) v + carry;
//             carry = (int) (cur / base);
//             z[i] = (int) (cur % base);
//             //asm("divl %%ecx" : "=a"(carry), "=d"(a[i]) : "A"(cur), "c"(base));
//         }
//         trim();
//     }

//     bigint operator*(int v) const {
//         bigint res = *this;
//         res *= v;
//         return res;
//     }

//     friend pair<bigint, bigint> divmod(const bigint &a1, const bigint &b1) {
//         int norm = base / (b1.z.back() + 1);
//         bigint a = a1.abs() * norm;
//         bigint b = b1.abs() * norm;
//         bigint q, r;
//         q.z.resize(a.z.size());

//         for (int i = a.z.size() - 1; i >= 0; i--) {
//             r *= base;
//             r += a.z[i];
//             int s1 = b.z.size() < r.z.size() ? r.z[b.z.size()] : 0;
//             int s2 = b.z.size() - 1 < r.z.size() ? r.z[b.z.size() - 1] : 0;
//             int d = ((long long) s1 * base + s2) / b.z.back();
//             r -= b * d;
//             while (r < 0)
//                 r += b, --d;
//             q.z[i] = d;
//         }

//         q.sign = a1.sign * b1.sign;
//         r.sign = a1.sign;
//         q.trim();
//         r.trim();
//         return make_pair(q, r / norm);
//     }

//     friend bigint sqrt(const bigint &a1) {
//         bigint a = a1;
//         while (a.z.empty() || a.z.size() % 2 == 1)
//             a.z.push_back(0);

//         int n = a.z.size();

//         int firstDigit = (int) sqrt((double) a.z[n - 1] * base + a.z[n - 2]);
//         int norm = base / (firstDigit + 1);
//         a *= norm;
//         a *= norm;
//         while (a.z.empty() || a.z.size() % 2 == 1)
//             a.z.push_back(0);

//         bigint r = (long long) a.z[n - 1] * base + a.z[n - 2];
//         firstDigit = (int) sqrt((double) a.z[n - 1] * base + a.z[n - 2]);
//         int q = firstDigit;
//         bigint res;

//         for(int j = n / 2 - 1; j >= 0; j--) {
//             for(; ; --q) {
//                 bigint r1 = (r - (res * 2 * base + q) * q) * base * base + (j > 0 ? (long long) a.z[2 * j - 1] * base + a.z[2 * j - 2] : 0);
//                 if (r1 >= 0) {
//                     r = r1;
//                     break;
//                 }
//             }
//             res *= base;
//             res += q;

//             if (j > 0) {
//                 int d1 = res.z.size() + 2 < r.z.size() ? r.z[res.z.size() + 2] : 0;
//                 int d2 = res.z.size() + 1 < r.z.size() ? r.z[res.z.size() + 1] : 0;
//                 int d3 = res.z.size() < r.z.size() ? r.z[res.z.size()] : 0;
//                 q = ((long long) d1 * base * base + (long long) d2 * base + d3) / (firstDigit * 2);
//             }
//         }

//         res.trim();
//         return res / norm;
//     }

//     bigint operator/(const bigint &v) const {
//         return divmod(*this, v).first;
//     }

//     bigint operator%(const bigint &v) const {
//         return divmod(*this, v).second;
//     }

//     void operator/=(int v) {
//         if (v < 0)
//             sign = -sign, v = -v;
//         for (int i = (int) z.size() - 1, rem = 0; i >= 0; --i) {
//             long long cur = z[i] + rem * (long long) base;
//             z[i] = (int) (cur / v);
//             rem = (int) (cur % v);
//         }
//         trim();
//     }

//     bigint operator/(int v) const {
//         bigint res = *this;
//         res /= v;
//         return res;
//     }

//     int operator%(int v) const {
//         if (v < 0)
//             v = -v;
//         int m = 0;
//         for (int i = z.size() - 1; i >= 0; --i)
//             m = (z[i] + m * (long long) base) % v;
//         return m * sign;
//     }

//     void operator+=(const bigint &v) {
//         *this = *this + v;
//     }
//     void operator-=(const bigint &v) {
//         *this = *this - v;
//     }
//     void operator*=(const bigint &v) {
//         *this = *this * v;
//     }
//     void operator/=(const bigint &v) {
//         *this = *this / v;
//     }

//     bool operator<(const bigint &v) const {
//         if (sign != v.sign)
//             return sign < v.sign;
//         if (z.size() != v.z.size())
//             return z.size() * sign < v.z.size() * v.sign;
//         for (int i = z.size() - 1; i >= 0; i--)
//             if (z[i] != v.z[i])
//                 return z[i] * sign < v.z[i] * sign;
//         return false;
//     }

//     bool operator>(const bigint &v) const {
//         return v < *this;
//     }
//     bool operator<=(const bigint &v) const {
//         return !(v < *this);
//     }
//     bool operator>=(const bigint &v) const {
//         return !(*this < v);
//     }
//     bool operator==(const bigint &v) const {
//         return !(*this < v) && !(v < *this);
//     }
//     bool operator!=(const bigint &v) const {
//         return *this < v || v < *this;
//     }

//     void trim() {
//         while (!z.empty() && z.back() == 0)
//             z.pop_back();
//         if (z.empty())
//             sign = 1;
//     }

//     bool isZero() const {
//         return z.empty() || (z.size() == 1 && !z[0]);
//     }

//     bigint operator-() const {
//         bigint res = *this;
//         res.sign = -sign;
//         return res;
//     }

//     bigint abs() const {
//         bigint res = *this;
//         res.sign *= res.sign;
//         return res;
//     }

//     long long longValue() const {
//         long long res = 0;
//         for (int i = z.size() - 1; i >= 0; i--)
//             res = res * base + z[i];
//         return res * sign;
//     }

//     friend bigint gcd(const bigint &a, const bigint &b) {
//         return b.isZero() ? a : gcd(b, a % b);
//     }
//     friend bigint lcm(const bigint &a, const bigint &b) {
//         return a / gcd(a, b) * b;
//     }

//     void read(const string &s) {
//         sign = 1;
//         z.clear();
//         int pos = 0;
//         while (pos < (int) s.size() && (s[pos] == '-' || s[pos] == '+')) {
//             if (s[pos] == '-')
//                 sign = -sign;
//             ++pos;
//         }
//         for (int i = s.size() - 1; i >= pos; i -= base_digits) {
//             int x = 0;
//             for (int j = max(pos, i - base_digits + 1); j <= i; j++)
//                 x = x * 10 + s[j] - '0';
//             z.push_back(x);
//         }
//         trim();
//     }

//     friend istream& operator>>(istream &stream, bigint &v) {
//         string s;
//         stream >> s;
//         v.read(s);
//         return stream;
//     }

//     friend ostream& operator<<(ostream &stream, const bigint &v) {
//         if (v.sign == -1)
//             stream << '-';
//         stream << (v.z.empty() ? 0 : v.z.back());
//         for (int i = (int) v.z.size() - 2; i >= 0; --i)
//             stream << setw(base_digits) << setfill('0') << v.z[i];
//         return stream;
//     }

//     static vector<int> convert_base(const vector<int> &a, int old_digits, int new_digits) {
//         vector<long long> p(max(old_digits, new_digits) + 1);
//         p[0] = 1;
//         for (int i = 1; i < (int) p.size(); i++)
//             p[i] = p[i - 1] * 10;
//         vector<int> res;
//         long long cur = 0;
//         int cur_digits = 0;
//         for (int i = 0; i < (int) a.size(); i++) {
//             cur += a[i] * p[cur_digits];
//             cur_digits += old_digits;
//             while (cur_digits >= new_digits) {
//                 res.push_back(int(cur % p[new_digits]));
//                 cur /= p[new_digits];
//                 cur_digits -= new_digits;
//             }
//         }
//         res.push_back((int) cur);
//         while (!res.empty() && res.back() == 0)
//             res.pop_back();
//         return res;
//     }

//     typedef vector<long long> vll;

//     static vll karatsubaMultiply(const vll &a, const vll &b) {
//         int n = a.size();
//         vll res(n + n);
//         if (n <= 32) {
//             for (int i = 0; i < n; i++)
//                 for (int j = 0; j < n; j++)
//                     res[i + j] += a[i] * b[j];
//             return res;
//         }

//         int k = n >> 1;
//         vll a1(a.begin(), a.begin() + k);
//         vll a2(a.begin() + k, a.end());
//         vll b1(b.begin(), b.begin() + k);
//         vll b2(b.begin() + k, b.end());

//         vll a1b1 = karatsubaMultiply(a1, b1);
//         vll a2b2 = karatsubaMultiply(a2, b2);

//         for (int i = 0; i < k; i++)
//             a2[i] += a1[i];
//         for (int i = 0; i < k; i++)
//             b2[i] += b1[i];

//         vll r = karatsubaMultiply(a2, b2);
//         for (int i = 0; i < (int) a1b1.size(); i++)
//             r[i] -= a1b1[i];
//         for (int i = 0; i < (int) a2b2.size(); i++)
//             r[i] -= a2b2[i];

//         for (int i = 0; i < (int) r.size(); i++)
//             res[i + k] += r[i];
//         for (int i = 0; i < (int) a1b1.size(); i++)
//             res[i] += a1b1[i];
//         for (int i = 0; i < (int) a2b2.size(); i++)
//             res[i + n] += a2b2[i];
//         return res;
//     }

//     bigint operator*(const bigint &v) const {
//         vector<int> a6 = convert_base(this->z, base_digits, 6);
//         vector<int> b6 = convert_base(v.z, base_digits, 6);
//         vll a(a6.begin(), a6.end());
//         vll b(b6.begin(), b6.end());
//         while (a.size() < b.size())
//             a.push_back(0);
//         while (b.size() < a.size())
//             b.push_back(0);
//         while (a.size() & (a.size() - 1))
//             a.push_back(0), b.push_back(0);
//         vll c = karatsubaMultiply(a, b);
//         bigint res;
//         res.sign = sign * v.sign;
//         for (int i = 0, carry = 0; i < (int) c.size(); i++) {
//             long long cur = c[i] + carry;
//             res.z.push_back((int) (cur % 1000000));
//             carry = (int) (cur / 1000000);
//         }
//         res.z = convert_base(res.z, 6, base_digits);
//         res.trim();
//         return res;
//     }
// };


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>

using namespace std;

#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define for1(i, n) for(int i = 1; i <= int(n); ++i)
#define ford(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define sz(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define X first
#define Y second
#define mp make_pair
#define debug(x) {cerr << #x << " = " << x << endl;}
template<typename T> inline T abs(T a){ return ((a < 0) ? -a : a); }
template<typename T> inline T sqr(T a){ return a * a; }

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int INF = (int)1E9 + 7;
const ld EPS = 1E-9;
const ld PI = 3.1415926535897932384626433832795;

int n, x[300000];

ld ans[50];

bool can(ld d){
    ld rg = -1E100;
    int it = 0;

    forn(i, n){

        if(fabs(x[i]-rg) < EPS) continue;
        if(x[i] <= rg) continue;

        ans[it++] = x[i]+d;
        rg = max(x[i]+2*d, rg);

        if(it > 3) break;
    }

    return it <= 3;
}

int main() {
    #ifdef my_project
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    #endif

    scanf("%d", &n);
    forn(i, n)
        scanf("%d", &x[i]);
    sort(x, x+n);
    n = unique(x, x+n)-x;

    ld lf = 0.0, rg = 1E9+7;
    forn(i, 100){
        ld mid = (lf+rg) / 2;
        if(can(mid))
            rg = mid;
        else
            lf = mid;
    }

    can(rg);

    cout.precision(6);
    cout << fixed;
    cout << (lf+rg)/2 << endl;
    forn(i, 3)
        cout << min(max(0.0L, ans[i]), 1E9L+100) << " ";
    cout << endl;

    return 0;
}


/**
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
Make it happen now, not tomorrow.
Tomorrow is a  loser's excuse.
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
**/
#ifndef _GLIbCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplu >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <cstring>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include<random>
#include <chrono>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplu >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#endif
#define __ ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
// #define INF 0x7f7f7f7f
#define ull unsigned long long int
#define pii pair<int,int>
#define ll long long int
#define ld long double
#define MSET(x,y) memset(x,y,sizeof(x))
// #define l long
#define se second
#define AlphaSize 26
#define fi first
#define NIL 0
#define UNVISITED -1
#define EXPOLORED 0
#define mk make_pair
#define pb push_back
#define sc(n) scanf("%d",&n)
#define NIL 0
#define db double
#define pii pair<int,int>
#define eps 1e-8
#define inrange(x,y,n,m) ((x>=1 && y>=1 && x<=n && y<=m))
#define all(x) x.begin(),x.end()
#define me(u,v,w) make_pair(w,make_pair(u,v))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define foreach(e, x) for(__typeof(x.begin()) e = x.begin(); e != x.end(); ++ e)
// #define add(a,b) (a + b >= MOD ? a+b-MOD:a+b)
#define hs(c1,c2) (256*min(c1,c2) + max(c1,c2))
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef struct{ int sum,suf,pre,max;} Node;
int toint(const string &s) { stringstream ss; ss << s; int x; ss >> x; return x; }
const int MAXN = 2e5+100;
const int UP = 31;
// const ll inf = 1e18;
// const int mod = 1e9+7;
const ll highest = 1e18;
// const int inf = 1e9+10;
// const dou    ble pi = 3.141592653589793238462643383;
const double pi = acos(-1);
const double Phi =  1.618033988749894;
const int logn = 20;
const double root5 = 2.236067977;
const ll inf = 1e18;
const int mod = 998244353;
const int ini = -1e9;
/**
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
Make it happen now, not tomorrow.
Tomorrow is a loser's excuse.
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
**/
//E.cpp
const int N = 2e5+10;
double x[N];
int n;
double l,r;
long double ans[3];
bool solve(double d){
    double range = -1e10;
    int it = 0;
    for(int i=0;i<n;++i){
        if(fabs(x[i]-range)<eps)continue;
        if(x[i]<=range)continue;
        ans[it++] = x[i] + d;
        range = max(range,x[i]+d+d);
        if(it>3)break;
    }
    return (it<=3);
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        cin>>x[i];
        // r = max(r,x[i]);
    }
    sort(x,x+n);
    n = unique(x,x+n) - x;
    l = 0;
    r = 1e9;
    for(int it=0;it<200;++it){
        double m = (l + r)/2.;
        if(solve(m)){
            r = m;
        }else{
            l = m;
        }
    }
    printf("%.7lf\n", (l+r)/2.);
    for(int i=0;i<3;++i){
        double an = min(max(0.0L,ans[i]),1E9L+100);
        printf("%.7lf ",an);
    }
    cout<<endl;
    return 0;
}
// struct bigint {
//     vector<int> z;
//     int sign;

//     bigint() :
//         sign(1) {
//     }

//     bigint(long v) {
//         *this = v;
//     }

//     bigint(const string &s) {
//         read(s);
//     }

//     void operator=(const bigint &v) {
//         sign = v.sign;
//         z = v.z;tor=(long long v) {
//         sign = 1;
//         if (v < return 0;0)
//             sign = -1, v = -v;
//         z.clear();
//         for (; v > 0; v = v / base)
//             z.push_back(v % base);
//     }

//     bigint operator+(const bigint &v) const {
//         if (sign == v.sign) {
//             bigint res = v;

//             for (int i = 0, carry = 0; i < (int) max(z.size(), v.z.size()) || carry; ++i) {
//                 if (i == (int) res.z.size())
//                     res.z.push_back(0);
//                 res.z[i] += carry + (i < (int) z.size() ? z[i] : 0);
//                 carry = res.z[i] >= base;
//                 if (carry)
//                     res.z[i] -= base;
//             }
//             return res;
//         }
//         return *this - (-v);
//     }

//     bigint operator-(const bigint &v) const {
//         if (sign == v.sign) {
//             if (abs() >= v.abs()) {
//                 bigint res = *this;
//                 for (int i = 0, carry = 0; i < (int) v.z.size() || carry; ++i) {
//                     res.z[i] -= carry + (i < (int) v.z.size() ? v.z[i] : 0);
//                     carry = res.z[i] < 0;
//                     if (carry)
//                         res.z[i] += base;
//                 }
//                 res.trim();
//                 return res;
//             }
//             return -(v - *this);
//         }
//         return *this + (-v);
//     }

//     void operator*=(int v) {
//         if (v < 0)
//             sign = -sign, v = -v;
//         for (int i = 0, carry = 0; i < (int) z.size() || carry; ++i) {
//             if (i == (int) z.size())
//                 z.push_back(0);
//             long long cur = z[i] * (long long) v + carry;
//             carry = (int) (cur / base);
//             z[i] = (int) (cur % base);
//             //asm("divl %%ecx" : "=a"(carry), "=d"(a[i]) : "A"(cur), "c"(base));
//         }
//         trim();
//     }

//     bigint operator*(int v) const {
//         bigint res = *this;
//         res *= v;
//         return res;
//     }

//     friend pair<bigint, bigint> divmod(const bigint &a1, const bigint &b1) {
//         int norm = base / (b1.z.back() + 1);
//         bigint a = a1.abs() * norm;
//         bigint b = b1.abs() * norm;
//         bigint q, r;
//         q.z.resize(a.z.size());

//         for (int i = a.z.size() - 1; i >= 0; i--) {
//             r *= base;
//             r += a.z[i];
//             int s1 = b.z.size() < r.z.size() ? r.z[b.z.size()] : 0;
//             int s2 = b.z.size() - 1 < r.z.size() ? r.z[b.z.size() - 1] : 0;
//             int d = ((long long) s1 * base + s2) / b.z.back();
//             r -= b * d;
//             while (r < 0)
//                 r += b, --d;
//             q.z[i] = d;
//         }

//         q.sign = a1.sign * b1.sign;
//         r.sign = a1.sign;
//         q.trim();
//         r.trim();
//         return make_pair(q, r / norm);
//     }

//     friend bigint sqrt(const bigint &a1) {
//         bigint a = a1;
//         while (a.z.empty() || a.z.size() % 2 == 1)
//             a.z.push_back(0);

//         int n = a.z.size();

//         int firstDigit = (int) sqrt((double) a.z[n - 1] * base + a.z[n - 2]);
//         int norm = base / (firstDigit + 1);
//         a *= norm;
//         a *= norm;
//         while (a.z.empty() || a.z.size() % 2 == 1)
//             a.z.push_back(0);

//         bigint r = (long long) a.z[n - 1] * base + a.z[n - 2];
//         firstDigit = (int) sqrt((double) a.z[n - 1] * base + a.z[n - 2]);
//         int q = firstDigit;
//         bigint res;

//         for(int j = n / 2 - 1; j >= 0; j--) {
//             for(; ; --q) {
//                 bigint r1 = (r - (res * 2 * base + q) * q) * base * base + (j > 0 ? (long long) a.z[2 * j - 1] * base + a.z[2 * j - 2] : 0);
//                 if (r1 >= 0) {
//                     r = r1;
//                     break;
//                 }
//             }
//             res *= base;
//             res += q;

//             if (j > 0) {
//                 int d1 = res.z.size() + 2 < r.z.size() ? r.z[res.z.size() + 2] : 0;
//                 int d2 = res.z.size() + 1 < r.z.size() ? r.z[res.z.size() + 1] : 0;
//                 int d3 = res.z.size() < r.z.size() ? r.z[res.z.size()] : 0;
//                 q = ((long long) d1 * base * base + (long long) d2 * base + d3) / (firstDigit * 2);
//             }
//         }

//         res.trim();
//         return res / norm;
//     }

//     bigint operator/(const bigint &v) const {
//         return divmod(*this, v).first;
//     }

//     bigint operator%(const bigint &v) const {
//         return divmod(*this, v).second;
//     }

//     void operator/=(int v) {
//         if (v < 0)
//             sign = -sign, v = -v;
//         for (int i = (int) z.size() - 1, rem = 0; i >= 0; --i) {
//             long long cur = z[i] + rem * (long long) base;
//             z[i] = (int) (cur / v);
//             rem = (int) (cur % v);
//         }
//         trim();
//     }

//     bigint operator/(int v) const {
//         bigint res = *this;
//         res /= v;
//         return res;
//     }

//     int operator%(int v) const {
//         if (v < 0)
//             v = -v;
//         int m = 0;
//         for (int i = z.size() - 1; i >= 0; --i)
//             m = (z[i] + m * (long long) base) % v;
//         return m * sign;
//     }

//     void operator+=(const bigint &v) {
//         *this = *this + v;
//     }
//     void operator-=(const bigint &v) {
//         *this = *this - v;
//     }
//     void operator*=(const bigint &v) {
//         *this = *this * v;
//     }
//     void operator/=(const bigint &v) {
//         *this = *this / v;
//     }

//     bool operator<(const bigint &v) const {
//         if (sign != v.sign)
//             return sign < v.sign;
//         if (z.size() != v.z.size())
//             return z.size() * sign < v.z.size() * v.sign;
//         for (int i = z.size() - 1; i >= 0; i--)
//             if (z[i] != v.z[i])
//                 return z[i] * sign < v.z[i] * sign;
//         return false;
//     }

//     bool operator>(const bigint &v) const {
//         return v < *this;
//     }
//     bool operator<=(const bigint &v) const {
//         return !(v < *this);
//     }
//     bool operator>=(const bigint &v) const {
//         return !(*this < v);
//     }
//     bool operator==(const bigint &v) const {
//         return !(*this < v) && !(v < *this);
//     }
//     bool operator!=(const bigint &v) const {
//         return *this < v || v < *this;
//     }

//     void trim() {
//         while (!z.empty() && z.back() == 0)
//             z.pop_back();
//         if (z.empty())
//             sign = 1;
//     }

//     bool isZero() const {
//         return z.empty() || (z.size() == 1 && !z[0]);
//     }

//     bigint operator-() const {
//         bigint res = *this;
//         res.sign = -sign;
//         return res;
//     }

//     bigint abs() const {
//         bigint res = *this;
//         res.sign *= res.sign;
//         return res;
//     }

//     long long longValue() const {
//         long long res = 0;
//         for (int i = z.size() - 1; i >= 0; i--)
//             res = res * base + z[i];
//         return res * sign;
//     }

//     friend bigint gcd(const bigint &a, const bigint &b) {
//         return b.isZero() ? a : gcd(b, a % b);
//     }
//     friend bigint lcm(const bigint &a, const bigint &b) {
//         return a / gcd(a, b) * b;
//     }

//     void read(const string &s) {
//         sign = 1;
//         z.clear();
//         int pos = 0;
//         while (pos < (int) s.size() && (s[pos] == '-' || s[pos] == '+')) {
//             if (s[pos] == '-')
//                 sign = -sign;
//             ++pos;
//         }
//         for (int i = s.size() - 1; i >= pos; i -= base_digits) {
//             int x = 0;
//             for (int j = max(pos, i - base_digits + 1); j <= i; j++)
//                 x = x * 10 + s[j] - '0';
//             z.push_back(x);
//         }
//         trim();
//     }

//     friend istream& operator>>(istream &stream, bigint &v) {
//         string s;
//         stream >> s;
//         v.read(s);
//         return stream;
//     }

//     friend ostream& operator<<(ostream &stream, const bigint &v) {
//         if (v.sign == -1)
//             stream << '-';
//         stream << (v.z.empty() ? 0 : v.z.back());
//         for (int i = (int) v.z.size() - 2; i >= 0; --i)
//             stream << setw(base_digits) << setfill('0') << v.z[i];
//         return stream;
//     }

//     static vector<int> convert_base(const vector<int> &a, int old_digits, int new_digits) {
//         vector<long long> p(max(old_digits, new_digits) + 1);
//         p[0] = 1;
//         for (int i = 1; i < (int) p.size(); i++)
//             p[i] = p[i - 1] * 10;
//         vector<int> res;
//         long long cur = 0;
//         int cur_digits = 0;
//         for (int i = 0; i < (int) a.size(); i++) {
//             cur += a[i] * p[cur_digits];
//             cur_digits += old_digits;
//             while (cur_digits >= new_digits) {
//                 res.push_back(int(cur % p[new_digits]));
//                 cur /= p[new_digits];
//                 cur_digits -= new_digits;
//             }
//         }
//         res.push_back((int) cur);
//         while (!res.empty() && res.back() == 0)
//             res.pop_back();
//         return res;
//     }

//     typedef vector<long long> vll;

//     static vll karatsubaMultiply(const vll &a, const vll &b) {
//         int n = a.size();
//         vll res(n + n);
//         if (n <= 32) {
//             for (int i = 0; i < n; i++)
//                 for (int j = 0; j < n; j++)
//                     res[i + j] += a[i] * b[j];
//             return res;
//         }

//         int k = n >> 1;
//         vll a1(a.begin(), a.begin() + k);
//         vll a2(a.begin() + k, a.end());
//         vll b1(b.begin(), b.begin() + k);
//         vll b2(b.begin() + k, b.end());

//         vll a1b1 = karatsubaMultiply(a1, b1);
//         vll a2b2 = karatsubaMultiply(a2, b2);

//         for (int i = 0; i < k; i++)
//             a2[i] += a1[i];
//         for (int i = 0; i < k; i++)
//             b2[i] += b1[i];

//         vll r = karatsubaMultiply(a2, b2);
//         for (int i = 0; i < (int) a1b1.size(); i++)
//             r[i] -= a1b1[i];
//         for (int i = 0; i < (int) a2b2.size(); i++)
//             r[i] -= a2b2[i];

//         for (int i = 0; i < (int) r.size(); i++)
//             res[i + k] += r[i];
//         for (int i = 0; i < (int) a1b1.size(); i++)
//             res[i] += a1b1[i];
//         for (int i = 0; i < (int) a2b2.size(); i++)
//             res[i + n] += a2b2[i];
//         return res;
//     }

//     bigint operator*(const bigint &v) const {
//         vector<int> a6 = convert_base(this->z, base_digits, 6);
//         vector<int> b6 = convert_base(v.z, base_digits, 6);
//         vll a(a6.begin(), a6.end());
//         vll b(b6.begin(), b6.end());
//         while (a.size() < b.size())
//             a.push_back(0);
//         while (b.size() < a.size())
//             b.push_back(0);
//         while (a.size() & (a.size() - 1))
//             a.push_back(0), b.push_back(0);
//         vll c = karatsubaMultiply(a, b);
//         bigint res;
//         res.sign = sign * v.sign;
//         for (int i = 0, carry = 0; i < (int) c.size(); i++) {
//             long long cur = c[i] + carry;
//             res.z.push_back((int) (cur % 1000000));
//             carry = (int) (cur / 1000000);
//         }
//         res.z = convert_base(res.z, 6, base_digits);
//         res.trim();
//         return res;
//     }
// };


#include <bits/stdc++.h>
using namespace std;
#define ld long double
vector<ld> x;
ld pos0, pos1, pos2;
bool check(ld d)
{
    int n = x.size();
    vector<ld> l(3), r(3), temp(3);
    int idx = 0;
    for (int i = 0; i < 3; i++)
    {
        l[i] = x[idx];
        r[i] = l[i] + 2 * d;
        int idx1 = upper_bound(x.begin(), x.end(), r[i]) - x.begin();
        if (idx1 == n)
        {
            for (int j = i; j < 3; j++)
                temp[j] = l[i] + d;
            pos0 = temp[0];
            pos1 = temp[1];
            pos2 = temp[2];
            // cout<<"pos0: "<<pos0<<" pos1 "<<pos1<<" pos2: "<<pos2<<endl;
            return true;
        }
        if (x[idx1] > r[i])
        {
            idx = idx1;
        }
        else
        {
            idx = idx1 + 1;
        }
        temp[i] = l[i] + d;
        if (idx == n)
        {
            for (int j = i; j < 3; j++)
                temp[j] = l[i] + d;
            pos0 = temp[0];
            pos1 = temp[1];
            pos2 = temp[2];
            // cout<<"pos0: "<<pos0<<" pos1 "<<pos1<<" pos2: "<<pos2<<endl;
            return true;
        }
    }
    return false;
}
int main()
{
    int n;
    cin >> n;
    x = vector<ld>(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    ld eps = 1e-7, start = -1 * eps, end = 1e9;
    while (end - start > eps)
    {
        ld mid = (start + end) / 2;
        // cout<<"start: "<<start<<" end: "<<end<<" mid: "<<mid<<endl;
        int flag = check(mid);
        // cout<<"flag: "<<flag<<endl;
        if (flag)
            end = mid;
        else
            start = mid;
    }
    cout << fixed;
    cout << setprecision(6) << end << "\n";
    cout << setprecision(7) << pos0 << " " << setprecision(7) << pos1 << " " << setprecision(7) << pos2 << "\n";
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define N 100005
#define M 1000005
//#define mod 1e9+7

using namespace std;

typedef pair<int,int> ii;
typedef pair<ll,ll> lii;
typedef vector<int> vi;
typedef vector<ii> vii;
const double pi = acos(-1);
const int inf = 2e9;

int n , a[2*N];
vector<double> vd;

bool ok(double x) {
      int cnt = 0 , boundary = -1;

      for(int i = 0; i < n; ++i) {
            if(a[i] > boundary) {
                  boundary = a[i] + 2*x;
                  ++cnt;
                  vd.pb(a[i] + x);
            }
      }

      return cnt <= 3;
}

int main() {

      #ifndef ONLINE_JUDGE
            freopen("in.in", "r", stdin);
            freopen("out.in", "w", stdout);
      #endif
            scanf("%d" , &n);
            for(int i = 0; i < n; ++i)
                  scanf("%d" , a + i);
            sort(a , a + n);

            double lo = 0 , hi = 2e9 , mid , ans;
            for(int i = 0; i < 100; ++i) {
                  mid = (hi + lo) / 2.0;
                  vd.clear();
                  if(ok(mid))
                        hi = mid;
                  else
                        lo = mid;
            }
            printf("%.6f\n" , hi);
            for(int i = 0; i < 3; ++i)
                  printf("%.6f " , vd[i]);

      return 0;

}


#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define N 100005
#define M 1000005
//#define mod 1e9+7

using namespace std;

typedef pair<int,int> ii;
typedef pair<ll,ll> lii;
typedef vector<int> vi;
typedef vector<ii> vii;
const double pi = acos(-1);
const int inf = 2e9;

int n , a[N];
vector<double> vd;

bool ok(double x) {
      int cnt = 0 , boundary = -1;

      for(int i = 0; i < n; ++i) {
            if(a[i] > boundary) {
                  boundary = a[i] + 2*x;
                  ++cnt;
                  vd.pb(a[i] + x);
            }
      }

      return cnt <= 3;
}

int main() {

      #ifndef ONLINE_JUDGE
            freopen("in.in", "r", stdin);
            freopen("out.in", "w", stdout);
      #endif
            scanf("%d" , &n);
            for(int i = 0; i < n; ++i)
                  scanf("%d" , a + i);
            sort(a , a + n);

            double lo = 0 , hi = 2e9 , mid , ans;
            for(int i = 0; i < 100; ++i) {
                  mid = (hi + lo) / 2.0;
                  vd.clear();
                  if(ok(mid))
                        hi = mid;
                  else
                        lo = mid;
            }
            printf("%.6f\n" , hi);
            for(int i = 0; i < 3; ++i)
                  printf("%.6f " , vd[i]);

      return 0;

}


#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define N 100005
#define M 1000005
//#define mod 1e9+7

using namespace std;

typedef pair<int,int> ii;
typedef pair<ll,ll> lii;
typedef vector<int> vi;
typedef vector<ii> vii;
const double pi = acos(-1);
const int inf = 2e9;

int n , a[N];
vector<double> vd;

bool ok(double x) {
      int cnt = 0 , boundary = -1;

      for(int i = 0; i < n; ++i) {
            if(a[i] > boundary) {
                  boundary = a[i] + 2*x;
                  ++cnt;
                  vd.pb(a[i] + x);
            }
      }

      return cnt <= 3;
}

int main() {

      #ifndef ONLINE_JUDGE
            freopen("in.in", "r", stdin);
            freopen("out.in", "w", stdout);
      #endif
            scanf("%d" , &n);
            for(int i = 0; i < n; ++i)
                  scanf("%d" , a + i);
            sort(a , a + n);

            double lo = 0 , hi = 2e9 , mid , ans;
            for(int i = 0; i < 1000; ++i) {
                  mid = (hi + lo) / 2.0;
                  vd.clear();
                  if(ok(mid))
                        hi = mid;
                  else
                        lo = mid;
            }
            printf("%.6f\n" , hi);
            for(int i = 0; i < 3; ++i)
                  printf("%.6f " , vd[i]);

      return 0;

}


#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define N 100005
#define M 1000005
//#define mod 1e9+7

using namespace std;

typedef pair<int,int> ii;
typedef pair<ll,ll> lii;
typedef vector<int> vi;
typedef vector<ii> vii;
const double pi = acos(-1);
const int inf = 2e9;

int n , a[2*N];
vector<double> vd;

bool ok(double x) {
      int cnt = 0;
      double boundary = -1;

      for(int i = 0; i < n; ++i) {
            if(a[i] > boundary) {
                  boundary = a[i] + 2*x;
                  ++cnt;
                  vd.pb(a[i] + x);
            }
      }

      return cnt <= 3;
}

int main() {

      #ifndef ONLINE_JUDGE
            freopen("in.in", "r", stdin);
            freopen("out.in", "w", stdout);
      #endif
            scanf("%d" , &n);
            for(int i = 0; i < n; ++i)
                  scanf("%d" , a + i);
            sort(a , a + n);

            double lo = 0 , hi = 2e9 , mid , ans;
            for(int i = 0; i < 100; ++i) {
                  mid = (hi + lo) / 2.0;
                  vd.clear();
                  if(ok(mid))
                        hi = mid;
                  else
                        lo = mid;
            }
            printf("%.6f\n" , hi);
            for(int i = 0; i < 3; ++i)
                  printf("%.6f " , vd[i]);

      return 0;

}


#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

bool isCovered( std::vector<int>& houses, double d )
{
	double left_upper = houses[0]+2*d;
	double right_lower = houses[houses.size()-1]-2*d;
	std::vector<int>::iterator lower, upper;
	lower = upper_bound( houses.begin(), houses.end(), left_upper );
	upper = lower_bound( houses.begin(), houses.end(), right_lower );
	upper = upper-1;
	// cout << *upper << ">=" << *lower << endl;
	return ( (*upper - *lower) <= 2*d );
}

int main(){
	int N;
	cin >> N;
	std::vector<int> houses;
	for( int i=0; i<N; i++ )
	{
		int input;
		cin >> input;
		houses.push_back( input );
	}
	sort( houses.begin(), houses.end() );
	double low, high, mid;
	low = 0;
	high = double(houses[houses.size()-1] - houses[0])/6.0;
	while( high - low > 1e-8  )
	{
		mid = (high+low)/2;
		if( isCovered( houses, mid ) )
		{
			high = mid;
		}else{
			low = mid;
		}
	}
	mid = (high+low)/2;
	cout << fixed << showpoint << setprecision(6) << mid << endl;
	double mid_base;
	int left_upper = int(houses[0]+2*mid+0.5);
	int right_lower = int(houses[houses.size()-1]-2*mid+0.5);
	std::vector<int>::iterator lower, upper;
	lower = upper_bound( houses.begin(), houses.end(), left_upper );
	upper = lower_bound( houses.begin(), houses.end(), right_lower );
	upper = upper-1;
	mid_base = double(*upper+*lower)/2.0;
	cout << double(houses[0]+mid) << " " << mid_base <<" "<< double(houses[houses.size()-1]-mid) <<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

bool isCovered( std::vector<int>& houses, double d )
{
	double left_upper = houses[0]+2*d;
	double right_lower = houses[houses.size()-1]-2*d;
	std::vector<int>::iterator lower, upper;
	lower = upper_bound( houses.begin(), houses.end(), left_upper );
	upper = lower_bound( houses.begin(), houses.end(), right_lower );
	upper = upper-1;
	// cout << *upper << ">=" << *lower << endl;
	return ( (*upper - *lower) <= 2*d );
}

int main(){
	int N;
	cin >> N;
	std::vector<int> houses;
	for( int i=0; i<N; i++ )
	{
		int input;
		cin >> input;
		houses.push_back( input );
	}
	sort( houses.begin(), houses.end() );
	double low, high, mid;
	low = 0;
	high = double(houses[houses.size()-1] - houses[0])/6.0;
	while( high - low > 1e-8  )
	{
		mid = (high+low)/2;
		if( isCovered( houses, mid ) )
		{
			high = mid;
		}else{
			low = mid;
		}
	}
	mid = (high+low)/2;
	cout << fixed << showpoint << setprecision(6) << mid << endl;
	double mid_base;
	int left_upper = int(houses[0]+2*mid+0.5);
	int right_lower = int(houses[houses.size()-1]-2*mid+0.5);
	std::vector<int>::iterator lower, upper;
	lower = upper_bound( houses.begin(), houses.end(), left_upper );
	upper = lower_bound( houses.begin(), houses.end(), right_lower );
	if( upper != houses.begin() )
		upper = upper-1;
	mid_base = double(*upper+*lower)/2.0;
	cout << double(houses[0]+mid) << " " << mid_base <<" "<< double(houses[houses.size()-1]-mid) <<endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

bool check_palindrome(string str){

	int l = 0;
    int h = str.size() - 1;

    while (h > l)
    {
        if (str[l++] != str[h--])
        {
            return false;
        }
    }
    return true;
}

int main(){
	int t;
	cin >> t;
	for(int i=0;i<t;i++){
		string s;
		cin >> s;
		if(check_palindrome(s)){
				char temp1;
				int index;
				int flag=0;
				int size= s.size()/2;
			if((count(s.begin(), s.end(), s[0])!=s.size())){

				if(!check_palindrome(s))
					cout << s <<endl;
			else{

				for(int i=0;i<size;i++){
					if(s[i]!=s[size]){

						temp1=s[i];
						index =i;
						flag=1;
						break;
					}
				}
				char temp3=s[size];
				s[size]=temp1;
				s[index]=temp3;
				if(!check_palindrome(s))
					cout << s <<endl;
			}
			}
			else{
				if(flag==0)
				cout << "-1" <<endl;
			}

		}
		else{
			cout << s <<endl;
		}
			}

	}


#include<bits/stdc++.h>

using namespace std;

bool check_palindrome(string str){

	int l = 0;
    int h = str.size() - 1;

    while (h > l)
    {
        if (str[l++] != str[h--])
        {
            return false;
        }
    }
    return true;
}

int main(){
	int t;
	cin >> t;
	for(int i=0;i<t;i++){
		string s;
		cin >> s;
		if(check_palindrome(s)){
			if(s.size()%2==0 && (count(s.begin(), s.end(), s[0])!=s.size())){

				char temp=s[0];
				s[0]=s[1];
				s[1]=temp;

			}
			else if(s.size()%2!=0 && (count(s.begin(), s.end(), s[0])!=s.size())){
				int size= s.size()/2;
				char temp1=s[size];
				s[size]=s[size+1];
				s[size+1]=temp1;

			}
			else{
				cout << "-1" <<endl;
			}

			if(!check_palindrome(s))
					cout << s <<endl;
			else{

				int size= s.size()/2;
				char temp1=s[size];
				s[size]=s[0];
				s[0]=temp1;
				if(!check_palindrome(s))
					cout << s <<endl;
			}
		}
		else{
			cout << s <<endl;
		}
			}

	}


#include<bits/stdc++.h>

using namespace std;

bool check_palindrome(string str){

	int l = 0;
    int h = str.size() - 1;

    while (h > l)
    {
        if (str[l++] != str[h--])
        {
            return false;
        }
    }
    return true;
}

int main(){
	int t;
	cin >> t;
	for(int i=0;i<t;i++){
		string s;
		cin >> s;
		if(check_palindrome(s)){
			if(s.size()%2==0 && (count(s.begin(), s.end(), s[0])!=s.size())){

				char temp=s[0];
				s[0]=s[1];
				s[1]=temp;

			}
			else if(s.size()%2!=0 && (count(s.begin(), s.end(), s[0])!=s.size())){
				int size= s.size()/2;
				char temp1=s[size];
				s[size]=s[size+1];
				s[size+1]=temp1;

			}
			else{
				cout << "-1" <<endl;
			}

			if(!check_palindrome(s))
					cout << s <<endl;
			else{
				char temp1;
				int index;
				int flag=0;
				int size= s.size()/2;
				for(int i=0;i<size;i++){
					if(s[i]!=s[size]){

						temp1=s[i];
						index =i;
						flag=1;
						break;
					}
				}
				char temp3=s[size];
				s[size]=temp1;
				s[index]=temp3;
				if(!check_palindrome(s))
					cout << s <<endl;
			}
		}
		else{
			cout << s <<endl;
		}
			}

	}


#include<bits/stdc++.h>

using namespace std;

bool check_palindrome(string str){

	int l = 0;
    int h = str.size() - 1;

    while (h > l)
    {
        if (str[l++] != str[h--])
        {
            return false;
        }
    }
    return true;
}

int main(){
	int t;
	cin >> t;
	for(int i=0;i<t;i++){
		string s;
		cin >> s;
		if(check_palindrome(s)){
			if(s.size()%2==0 && (count(s.begin(), s.end(), s[0])!=s.size())){

				char temp=s[0];
				s[0]=s[1];
				s[1]=temp;

			}
			else if(s.size()%2!=0 && (count(s.begin(), s.end(), s[0])!=s.size())){
				int size= s.size()/2;
				char temp1=s[size];
				s[size]=s[size+1];
				s[size+1]=temp1;

			}
			else{
				cout << "-1" <<endl;
			}

			if(!check_palindrome(s))
					cout << s <<endl;

		}
		else{
			cout << s <<endl;
		}

	}

}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int t;
    string s;
    cin >> t;
    while(t--){
        cin >> s;
        sort(s.begin(), s.end());
        if(s[0] != s[s.size()-1]) cout << s << '\n';
        else cout << -1 << '\n';
    }
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int t;
    string s;
    cin >> t;
    while(t--){
        cin >> s;
        sort(s.being(), s.end());
        if(s[0] != s[s.size()-1]) cout << s << '\n';
        else cout << -1 << '\n';
    }
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int t;
    string s;
    cin >> t;
    while(t--){
        cin >> s;
        bool flag = false;
        for(int i = 1; i < s.size(); i++){
            if(s[i] != s[i-1]){
                flag = true;
                break;
            }
        }
        if(flag){
            sort(s.begin(), s.end());
            cout << s[s.size()-1];
            for(int i = 0; i < s.size()-1; i++) cout << s[i];
        }
        else cout << -1;
        cout << '\n';
    }
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int t;
    string s;
    cin >> t;
    while(t--){
        cin >> s;
        bool flag = false;
        for(int i = 1; i < s.size(); i++){
            if(s[i] != s[i-1]){
                flag = true;
                break;
            }
        }
        if(flag){
            sort(s.begin(), s.end());
            if(s.size()%2 == 0){
                cout << s[s.size()-1];
                for(int i = 0; i < s.size()-1; i++) cout << s[i];
            }
            else cout << s;
        }
        else cout << -1;
        cout << '\n';
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char ch[1005];
int main(){
    int len;
    int d;
    int count;
    bool flag=0;
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%s",&ch);
        len=strlen(ch);
        if(len==1)
            printf("-1\n");
        flag=0;
        count=0;
        d=0;
        char b=ch[0];
        for(int i=0;i<len/2;i++){
            if(ch[i]-ch[0]>0){
                flag=1;
                count=i;
            }
            if(ch[i]==ch[len-i-1]){
                d++;
            }

        }
        if(d==len/2&&flag==1){
            printf("%c",ch[count]);
            for(int i=1;i<len;i++){
                if(i==count)
                    printf("%c",ch[0]);
                else
                    printf("%c",ch[i]);
            }
        }
        else if(d==len/2&&flag==0){
            printf("-1\n");
        }
        else
             printf("%s",ch);
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char ch[1005];
int main(){
    int len;
    int d;
    int count;
    bool flag=0;
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%s",&ch);
        len=strlen(ch);
        if(len==1)
            printf("-1\n");
        flag=0;
        count=0;
        d=0;
        char b=ch[0];
        for(int i=0;i<len/2;i++){
            if(ch[i]-ch[0]>0){
                flag=1;
                count=i;
            }
            if(ch[i]==ch[len-i-1]){
                d++;
            }

        }
        if(d==len/2&&flag==1){
            printf("%c",ch[count]);
            for(int i=1;i<len;i++){
                if(i==count)
                    printf("%c",ch[0]);
                else
                    printf("%c",ch[i]);
            }
        }
        else if(d==len/2&&flag==0){
            printf("-1");
        }
        else
             printf("%s",ch);
        printf("\n");
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char ch[1005];
int main(){
    int len;
    int d;
    int count;
    bool flag=0;
    int mmm;
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%s",&ch);
        len=strlen(ch);
        mmm=0;
        if(len==1)
            printf("-1\n");
        else if(len%2==1&&ch[len/2]!=ch[0]){
       printf("%c",ch[len/2]);
        for(int i=1;i<len;i++){
            if(i!=len/2)
                printf("%c",ch[i]);
        }
        printf("\n");}
        else{
            flag=0;
            count=0;
            d=0;
            char b=ch[0];
            for(int i=0;i<len/2;i++){
                if(ch[i]-ch[0]>0){
                    flag=1;
                    count=i;
                    mmm++;
                }
                if(ch[i]==ch[len-i-1]){
                    d++;
                }

            }
            if(d==len/2&&mmm>=2&&flag==1){
                printf("%c",ch[count]);
                for(int i=1;i<len;i++){
                    if(i==count)
                        printf("%c",ch[0]);
                    else
                        printf("%c",ch[i]);
                }
            }
            else if((d==len/2&&mmm==1)||(d==len/2&&flag==0)){
                printf("-1");
            }
            else
                printf("%s",ch);
            printf("\n");
        }}
        return 0;
    }


#include <bits/stdc++.h>

using namespace std;

int main() {
	int t;
	cin >> t;
	for (int i = 0; i < t; ++i) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		if (s[0] == s.back()) cout << -1 << endl;
		else cout << s << endl;
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char ch[1005];
int main(){
    int len;
    int d;
    int count;
    bool flag=0;
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%s",&ch);
        len=strlen(ch);
        flag=0;
        count=0;
        d=0;
        char b=ch[0];
        for(int i=0;i<len/2;i++){
            if(ch[i]-ch[0]>0){
                flag=1;
                count=i;
            }
            if(ch[i]==ch[len-i-1]){
                d++;
            }

        }
        if(d==len/2&&flag==1){
            printf("%c",ch[count]);
            for(int i=1;i<len;i++){
                if(i==count)
                    printf("%c",ch[0]);
                else
                    printf("%c",ch[i]);
            }
        }
        else
            printf("-1\n");
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char ch[1005];
int main(){
    int len;
    int d;
    int count;
    bool flag=0;
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%s",&ch);
        len=strlen(ch);
        flag=0;
        count=0;
        d=0;
        char b=ch[0];
        for(int i=0;i<len/2;i++){
            if(ch[i]-ch[0]>0){
                flag=1;
                count=i;
            }
            if(ch[i]==ch[len-i-1]){
                d++;
            }

        }
        if(d==len/2&&flag==1){
            printf("%c",ch[count]);
            for(int i=1;i<len;i++){
                if(i==count)
                    printf("%c",ch[0]);
                else
                    printf("%c",ch[i]);
            }
        }
        else if(d==len/2&&flag==0){
            printf("-1\n");
        }
        else
             printf("%s",ch);
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){

    int T;

    scanf("%d",&T);

    string s, t;

    while (T--){
        cin >> s;
        set <char> ss;
        map <char,int> mp;
        for (int i=0;i<s.length();i++){
            ss.insert(s[i]);
            mp[s[i]]++;
        }
        if (ss.size()==1){
            printf("-1\n");
            continue;
        }
        for (char i='a';i<='z';i++){
            if (mp[i]){
                int a = mp[i];
                while(a--)
                    cout << (char) i;
            }
        }
        printf("\n");
    }

    return 0;

}


#include <bits/stdc++.h>

using namespace std;

int gs_check(string s){
    string rs = s;
    int flag = 0;
    char c = s[0];
    for (int i=0;i<s.length();i++){
        if (s[i]==c)
            flag++;
    }
    reverse(rs.begin(),rs.end());
    if (rs==s&&flag==s.length())
        printf("-1");
    else if (rs==s&&flag!=s.length()){
        swap(s[0],s[1]);
        cout << s;
    }
    else if (rs!=s)
        cout << s;
}

int main(){

    int T;

    scanf("%d",&T);

    string s;

    while (T--){
        cin >> s;
        gs_check(s);
        printf("\n");
    }

    return 0;

}


#include <bits/stdc++.h>

using namespace std;

bool check(string s){
    char c = s[0];
    int flag = 0;
    for (int i=0;i<s.length();i++){
        if (s[i]==c)
            flag++;
    }
    if (flag==s.length())
        return true;
    else
        return false;
}

bool gs_check(string s){
    string rs = s;
    reverse(rs.begin(),rs.end());
    if (rs==s)
        return false;
    else
        return true;
}

int main(){

    int T;

    scanf("%d",&T);

    string s;

    while (T--){
        cin >> s;
        if (check(s))
            printf("-1\n");
        else if (!check(s)&&gs_check(s))
            cout << s << endl;
        else if (!check(s)&&!gs_check(s)){
            swap(s[0],s[1]);
            cout << s << endl;
        }
    }

    return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){

    int T;

    scanf("%d",&T);

    string s, t;

    while (T--){
        cin >> s;
        t = s;
        sort(s.begin(),s.end());
        if (s==t)
            printf("-1\n");
        else
            cout << s << endl;
    }

    return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){

    int T;

    scanf("%d",&T);

    string s, t;

    while (T--){
        cin >> s;
        int flag = 0;
        char c = s[0];
        for (int i=0;i<s.length();i++){
            if (s[i]==c)
                flag++;
        }
        if (flag==s.length())
            printf("-1\n");
        else{
            t = s;
            reverse(t.begin(),t.end());
            if (s==t)
                swap(s[0],s[1]);
            cout << s << endl;
        }
    }

    return 0;

}


#include <bits/stdc++.h>

using namespace std;

bool check(string s){
    char c = s[0];
    int flag = 0;
    for (int i=0;i<s.length();i++){
        if (s[i]==c)
            flag++;
    }
    if (flag==s.length())
        return true;
    else
        return false;
}

bool gs_check(string s){
    string rs = s;
    reverse(rs.begin(),rs.end());
    if (rs==s)
        return false;
    else
        return true;
}

int main(){

    int T;

    scanf("%d",&T);

    string s;

    while (T--){
        cin >> s;
        if (check(s))
            printf("-1\n");
        else if (gs_check(s))
            cout << s << endl;
        else if (!gs_check(s)){
            swap(s[0],s[1]);
            cout << s << endl;
        }
    }

    return 0;

}


#include <bits/stdc++.h>

using namespace std;

string reverse(string s){
    char f[s.size()];
    for (int i=0;i<s.size();i++)
        f[i]=s[s.size()-1-i];
    return (string)f;
}

string  diff_elt(string s){
    for (int i=1;i<s.size();i++)
        if (s[0]!=s[i])
            swap(s[0],s[i]);
    return s;
}

int main() {

    int t;string s,f;
    cin>>t;

    for (int i=0;i<t;i++){
        cin>>s;
        //cout<<"f="<<f<<"\n";

        if (diff_elt(s)==s){
            cout<<"-1\n";
        }
        else if ( reverse(s)==s){

            if (s.size()%2!=0){

                /*if (s.substr(0,(s.size()-1)/2)!=s.substr(((s.size()-1)/2)+1,s.size())) //checking if 0 to mid ==
                    cout<<s<<"\n";

                else */
                    cout<<diff_elt(s.substr(0,(s.size()-1)/2+1))<<s.substr(((s.size()-1)/2)+1,s.size())<<"\n";

            }

            else {

                cout<<diff_elt(s.substr(0,(s.size()-1)/2+2))<<s.substr(((s.size()-1)/2)+2,s.size())<<"\n";
            }
        }

        else cout<<s<<"\n";
    }

    return 0;
}


   #include <bits/stdc++.h>

using namespace std;

string reverse(string s){
    char f[s.size()];
    for (int i=0;i<s.size();i++)
        f[i]=s[s.size()-1-i];
    return (string)f;
}

string  diff_elt(string s){
    for (int i=1;i<s.size();i++)
        if (s[0]!=s[i])
            swap(s[0],s[i]);
    return s;
}

int main() {
    int t;string s,f;
    cin>>t;

    for (int i=0;i<t;i++){
        cin>>s;
        f=reverse(s);
        //cout<<"f="<<f<<"\n";

        if (diff_elt(s)==s){
            cout<<"-1\n";
        }
        else if (s.substr(0,(s.size()-1)/2)!=s.substr(((s.size()-1)/2)+1,s.size()))
            cout<<s<<"\n";
        else {

            cout<<diff_elt(s.substr(0,(s.size()-1)/2))<<s.substr(((s.size()-1)/2),s.size())<<"\n";

        }
    }
    return 0;
}


   #include <bits/stdc++.h>

using namespace std;

string reverse(string s){
    char f[s.size()];
    for (int i=0;i<s.size();i++)
        f[i]=s[s.size()-1-i];
    return (string)f;
}

string  diff_elt(string s){
    for (int i=1;i<s.size();i++)
        if (s[0]!=s[i])
            swap(s[0],s[i]);
    return s;
}

int main() {
    int t;string s,f;
    cin>>t;

    for (int i=0;i<t;i++){
        cin>>s;
        f=reverse(s);
        //cout<<"f="<<f<<"\n";

        if (diff_elt(s)==s){
            cout<<" -1\n";
        }
        else if (s!=f)
            cout<<s<<"\n";
        else {
            cout<<diff_elt( s)<<"\n";

        }
    }
    return 0;
}


   #include <bits/stdc++.h>

using namespace std;

string reverse(string s){
    char f[s.size()];
    for (int i=0;i<s.size();i++)
        f[i]=s[s.size()-1-i];
    return (string)f;
}

string  diff_elt(string s){
    for (int i=1;i<s.size();i++)
        if (s[0]!=s[i])
            swap(s[0],s[i]);
    return s;
}

int main() {
    int t;string s,f;
    cin>>t;

    for (int i=0;i<t;i++){
        cin>>s;
        //cout<<"f="<<f<<"\n";

        if (diff_elt(s)==s){
            cout<<"-1\n";
        }
        else if ( reverse(s)==s){

            if (s.size()%2!=0){

                /*if (s.substr(0,(s.size()-1)/2)!=s.substr(((s.size()-1)/2)+1,s.size())) //checking if 0 to mid ==
                    cout<<s<<"\n";

                else */
                    cout<<diff_elt(s.substr(0,(s.size()-1)/2+1))<<s.substr(((s.size()-1)/2)+1,s.size())<<"\n";

            }

            else {

                cout<<diff_elt(s.substr(0,(s.size()-1)/2+2))<<s.substr(((s.size()-1)/2)+2,s.size())<<"\n";
            }
        }
        else cout<<s;
    }
    return 0;
}


 #include <bits/stdc++.h>

using namespace std;

string reverse(string s){
    char f[s.size()];
    for (int i=0;i<s.size();i++)
        f[i]=s[s.size()-1-i];
    return (string)f;
}

bool palindrome (string s){
    string f =reverse(s);
    for (int i=0;i<s.size();i++)
        if (s[i]!=f[i])
            return false;
    return true;
}

string  diff_elt(string s){
    for (int i=1;i<s.size();i++)
        if (s[0]!=s[i])
            swap(s[0],s[i]);
    return s;
}

int main() {

    int t;string s,f;
    cin>>t;

    for (int i=0;i<t;i++){
        cin>>s;
        //cout<<"f="<<f<<"\n";

        if (diff_elt(s)==s){
            cout<<"-1\n";
        }
        else if (palindrome (s)==true){

            if (s.size()%2!=0)
                    cout<<diff_elt(s.substr(0,(s.size()-1)/2+1))<<s.substr(((s.size()-1)/2)+1,s.size())<<"\n";

            else
                cout<<diff_elt(s.substr(0,(s.size()-1)/2+2))<<s.substr(((s.size()-1)/2)+2,s.size())<<"\n";

        }

        else cout<<s<<"\n";
    }

    return 0;
}


   #include <bits/stdc++.h>

using namespace std;

string reverse(string s){
    char f[s.size()];
    for (int i=0;i<s.size();i++)
        f[i]=s[s.size()-1-i];
    return (string)f;
}

string  diff_elt(string s){
    for (int i=1;i<s.size();i++)
        if (s[0]!=s[i])
            swap(s[0],s[i]);
    return s;
}

int main() {
    int t;string s,f;
    cin>>t;

    for (int i=0;i<t;i++){
        cin>>s;
        f=reverse(s);
        //cout<<"f="<<f<<"\n";

        if (diff_elt(s)==s){
            cout<<"-1\n";
        }
        else if (s.substr(0,(s.size()-1)/2)!=s.substr(((s.size()-1)/2)+1,s.size()))
            cout<<s<<"\n";
        else {

            cout<<diff_elt(s.substr(0,(s.size()-1)/2+1))<<s.substr(((s.size()-1)/2)+1,s.size())<<"\n";

        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    ll n;
    cin >> n;

    for (ll i = 1; i <= n; i++){
        string s,p;
        cin >> s;
        p = s;
        sort(p.begin(), p.end());
        sort(s.begin(), s.end());
        reverse(p.begin(), p.end());
        if (p!=s) {cout << p << endl;}
        else cout << "-1" << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    ll n;
    cin >> n;

    for (ll i = 1; i <= n; i++){
        string s,p;
        cin >> s;
        p = s;
        sort(p.begin(), p.end());
        if (p==s) {cout << p << endl;}
        else cout << "-1" << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    ll n;
    cin >> n;

    for (ll i = 1; i <= n; i++){
        string s,p;
        cin >> s;
        p = s;
        stable_sort(p.begin(), p.end());
        if (p!=s) {cout << p << endl;}
        else cout << "-1" << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    ll n;
    cin >> n;

    for (ll i = 1; i <= n; i++){
        string s,p;
        cin >> s;
        p = s;
        sort(p.begin(), p.end());
        if (p!=s) {cout << p << endl;}
        else cout << "-1" << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    string s;
    cin >> s;

    bool flag = true;
    char p = s[0];

    for (ll i = 1; i < s.size(); i++){
        if(s[i]!=p){flag = false; break;}
    }

    if (flag){
            sort(s.begin(), s. end());
        cout << s;
    } else cout << "-1";

    return 0;
}


 #include <iostream>
 #include<string>
 #include <bits/stdc++.h>

using namespace std;

bool ispal(string s){
for (int i =0 ;i<s.size();i++){
    if (s[i]!=s[s.size()-i-1]){
        return false;
    }
}

return true;
}
int main()
{ int t;
cin>>t;
string s;
    bool b;
while(t--)
{
    cin>>s;
    sort (s.begin(),s.end());
    b=ispal(s);
    if (b==true)
        {cout<<"-1";}
else
        {

        cout<<s<<endl;
        }

    return 0;
}
}


 #include <iostream>
 #include<string>
 #include <algorithm>    // std::sort
#include <vector>

using namespace std;
string s;
bool ispal(){
for (int i =0 ;i<s.size();i++){
    if (s[i]!=s[s.size()-i-1]){
        return false;
    }
}

return true;
}
int main()
{ int t;
cin>>t;

while(t--)
{
    cin>>s;
    sort (s.begin(),s.end());

    if (ispal())
        {cout<<-1;}
else
        {

        cout<<s<<endl;
        }

}
    return 0;

}


 #include <iostream>
 #include<string>
 #include <algorithm>    // std::sort
#include <vector>

using namespace std;
string s;
bool ispal(){
for (int i =0 ;i<s.size();i++){
    if (s[i]!=s[s.size()-i-1]){
        return false;
    }
}

return true;
}
int main()
{ int t;
cin>>t;

while(t--)
{
    cin>>s;
    sort (s.begin(),s.end());

    if (ispal())
        {cout<<"-1";}
else
        {

        cout<<s<<endl;
        }

}
    return 0;

}


 #include <iostream>
 #include<string>
 #include <algorithm>    // std::sort
#include <vector>
using namespace std;

bool ispal(string s){
for (int i =0 ;i<s.size();i++){
    if (s[i]!=s[s.size()-i-1]){
        return false;
    }
}

return true;
}
int main()
{ int t;
cin>>t;
string s;
    bool b;
while(t--)
{
    cin>>s;
    sort (s.begin(),s.end());
    b=ispal(s);
    if (b==true)
        {cout<<"-1";}
else
        {

        cout<<s<<endl;
        cout<<"\n"<<endl;
        }

    return 0;
}
}


 #include <bits/stdc++.h>

using namespace std;
string s;
bool ispal(){
for (int i =0 ;i<s.size();i++){
    if (s[i]!=s[s.size()-i-1]){
        return 0;
    }
}

return 1;
}
int main()
{int T,n;
cin >>T;
while (T--){
    cin >>s;
    sort (s.begin(),s.end());
    if (ispal()){
        cout <<-1<<endl;
    }
    else {

    cout <<s<<endl;
    }
}
    return 0;
}


 #include <iostream>
 #include<string>
 #include <algorithm>    // std::sort
#include <vector>

using namespace std;

bool ispal(string s){
for (int i =0 ;i<s.size();i++){
    if (s[i]!=s[s.size()-i-1]){
        return false;
    }
}

return true;
}
int main()
{ int t;
cin>>t;

while(t!=0)
{ string s;
    cin>>s;
    sort (s.begin(),s.end());

    if (ispal(s))
        {cout<<"-1";}
else
        {

        cout<<s<<endl;
        }
t--;
}
    return 0;

}


 #include <iostream>
 #include<string>
 #include <algorithm>    // std::sort
#include <vector>

using namespace std;

bool ispal(string s){
for (int i =0 ;i<s.size();i++){
    if (s[i]!=s[s.size()-i-1]){
        return false;
    }
}

return true;
}
int main()
{ int t;
cin>>t;
string s;
    bool b;
while(t!=0)
{
    cin>>s;
    sort (s.begin(),s.end());
    b=ispal(s);
    if (b==true)
        {cout<<"-1";}
else
        {

        cout<<s<<endl;
        }

}
    return 0;

}


 #include <iostream>
 #include<string>
 #include <algorithm>    // std::sort
#include <vector>

using namespace std;

bool ispal(string s){
for (int i =0 ;i<s.size();i++){
    if (s[i]!=s[s.size()-i-1]){
        return false;
    }
}

return true;
}
int main()
{ int t;
cin>>t;

while(t--)
{ string s;
    cin>>s;
    sort (s.begin(),s.end());

    if (ispal(s))
        {cout<<"-1";}
else
        {

        cout<<s<<endl;
        }

}
    return 0;

}


 #include <iostream>
 #include<string>
 #include <algorithm>

using namespace std;
string s;
bool ispal()
{
for (int i =0 ;i<s.size();i++){
    if (s[i]!=s[s.size()-i-1]){
        return 0;
    }
}

return 1;
}
int main()
{ int t;
cin>>t;

while(t--)
{
    cin>>s;
    sort (s.begin(),s.end());

    if (ispal())
        {cout<<-1 ;
        cout<<"\n";}
else
        {

        cout<<s<<endl;
        }

}
    return 0;

}


 #include <iostream>
 #include<string>
 #include <algorithm>    // std::sort
#include <vector>

using namespace std;
string s;
bool ispal(){
for (int i =0 ;i<s.size();i++){
    if (s[i]!=s[s.size()-i-1]){
        return false;
    }
}

return true;
}
int main()
{ int t,n;
cin>>t;

while(t--)
{
    cin>>s;
    sort (s.begin(),s.end());

    if (ispal())
        {cout<<-1;}
else
        {

        cout<<s<<endl;
        }

}
    return 0;

}


#include<iostream>
using namespace std;

bool isPalindrome(string s){
	int len = s.length();
	int hLen = len/2;
	for(int i=0;i<=hLen;i++){
		if(s[i]!=s[len-1-i]){
			return false;
		}
	}
	return true;
}

bool bad(string s){
	int len = s.length();
	int hLen = len/2;
	for(int i=0;i<hLen;i++){
		if(s[i]!=s[i+1]){
			return false;
		}
	}
}

string rearrange(string s){
	int len = s.length();
	int hLen = len/2;
	for(int i=0;i<hLen;i++){
		if(s[i]!=s[i+1]){
			char c = s[i];
			s[i]=s[i+1];
			s[i+1]=c;
			return s;
		}
	}
}

int main(){
	int n;
	string data[100];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>data[i];
	}
	for(int i=0;i<n;i++){
		if(isPalindrome(data[i])){
			if(bad(data[i])){
				cout<<int(-1)<<endl;
			}else{
				string s = 	rearrange(data[i]);
				cout<<s<<endl;
			}
		}else{
			cout<<data[i]<<endl;
		}
	}

	char c;
	cin>>c;
	return 0;
}


#include<iostream>
using namespace std;

bool isPalindrome(string s){
	int len = s.length();
	int hLen = len/2;
	for(int i=0;i<=hLen;i++){
		if(s[i]!=s[len-1-i]){
			return false;
		}
	}
	return true;
}

bool bad(string s){
	int len = s.length();
	int hLen = len/2;
	for(int i=0;i<hLen;i++){
		if(s[i]!=s[i+1]){
			return false;
		}
	}
	return true;
}

string rearrange(string s){
	int len = s.length();
	int hLen = len/2;
	for(int i=0;i<hLen;i++){
		if(s[i]!=s[i+1]){
			char c = s[i];
			s[i]=s[i+1];
			s[i+1]=c;
			return s;
		}
	}
}

int main(){
	int n;
	string data[100];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>data[i];
	}
	for(int i=0;i<n;i++){
		if(isPalindrome(data[i])){
			if(bad(data[i])){
				cout<<int(-1)<<endl;
			}else{
				string s = 	rearrange(data[i]);
				cout<<s<<endl;
			}
		}else{
			cout<<data[i]<<endl;
		}
	}

	char c;
	cin>>c;
	return 0;
}


#include<iostream>
using namespace std;

bool isPalindrome(string s){
	int len = s.length();
	int hLen = len/2;
	for(int i=0;i<=hLen;i++){
		if(s[i]!=s[len-1-i]){
			return false;
		}
	}
	return true;
}

bool bad(string s){
	int len = s.length();
	int hLen = len/2;
	for(int i=0;i<hLen;i++){
		if(s[i]!=s[i+1]){
			return false;
		}
	}
}

string rearrange(string s){
	int len = s.length();
	int hLen = len/2;
	for(int i=0;i<hLen;i++){
		if(s[i]!=s[i+1]){
			char c = s[i];
			s[i]=s[i+1];
			s[i+1]=c;
			return s;
		}
	}
}

int main(){
	int n;
	string data[100];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>data[i];
	}
	for(int i=0;i<n;i++){
		if(isPalindrome(data[i])){
			if(bad(data[i])){
				cout<<int(-1)<<endl;
			}else{

				string s = 	rearrange(data[i]);
				cout<<s<<endl;
			}
		}else{
			cout<<data[i]<<endl;
		}
	}

	char c;
	cin>>c;
	return 0;
}


#include<iostream>
using namespace std;

bool isPalindrome(string s){
	int len = s.length();
	int hLen = len/2;
	for(int i=0;i<=hLen;i++){
		if(s[i]!=s[len-1-i]){
			return false;
		}
	}
	return true;
}

bool bad(string s){
	int len = s.length();
	int hLen = len/2;
	for(int i=0;i<hLen;i++){
		if(s[i]!=s[i+1]){
			return false;
		}
	}
	return true;
}

int main(){
	int n;
	string data[100];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>data[i];
	}
	for(int i=0;i<n;i++){
		if(isPalindrome(data[i])){
			if(bad(data[i])){
				cout<<int(-1)<<endl;
			}else{
				string s = data[i];
				char c = s[s.length()/2];
				s[s.length()/2]=s[s.length()/2+1];
				s[s.length()/2+1]=c;
				cout<<s<<endl;
			}
		}else{
			cout<<data[i]<<endl;
		}
	}

	char c;
	cin>>c;
	return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main() {
	int a, l, r, i=0, t; string str[10000];
	cin>> a;
	for (int q=0; q<a; q++)
	{
	    t=0;
	    i=0;
	    cin>>str[q];
	    if (str[q].length()==1||(str[q].length()==2&&str[q][0]==str[0][1])) {str[q]="-1";}
        else {
            r=str[q].length();
            for (int w=0; w<(str[q].length()/2); w++) {
                if (str[q][w]==str[q][str[q].length()-w-1]) continue;
                else { i++;}

            }
        if (i==0) {for (int w=0; w<str[q].length(); w++) {
                if (str[q][(str[q].length()-1)/2+1]!=str[q][w]){ swap(str[q][(str[q].length()-1)/2+1], str[q][w]);}
                else t++;
                }}
        if (t==str[q].length()) str[q]="-1";}}
        for (int q=0; q<a; q++) cout<<str[q]<<endl;

}


#include <iostream>
#include <string>

using namespace std;

int main() {
	int a, l, r, i=0, t; string str[10000];
	cin>> a;
	for (int q=0; q<a; q++)
	{
	    t=0;
	    i=0;
	    cin>>str[q];
	    if (str[q].length()==1||(str[q].length()==2&&str[q][0]==str[0][1])) {str[q]="-1";}
        else {
            r=str[q].length();
            for (int w=0; w<(str[q].length()/2); w++) {
                if (str[q][w]==str[q][str[q].length()-w-1]) continue;
                else { i++;}

            }
        if (i==0&&str[q].length()!=4) {for (int w=0; w<str[q].length(); w++) {
                if (str[q][(str[q].length()-1)/2+1]!=str[q][w]){ swap(str[q][(str[q].length()-1)/2+1], str[q][w]);}
                else if (str[q].length()==4) swap (str[q][0], str[q][1]);
                else  t++;
                }}
        if (t==str[q].length()) str[q]="-1";}}
        for (int q=0; q<a; q++) cout<<str[q]<<endl;

}


#include <iostream>
#include <string>

using namespace std;

int main() {
	int a, l, r, i=0, t; string str[10000];
	cin>> a;
	for (int q=0; q<a; q++)
	{
	    t=0;
	    i=0;
	    cin>>str[q];
	    if (str[q].length()==1||(str[q].length()==2&&str[q][0]==str[0][1])) {str[q]="-1";}
        else {
            r=str[q].length();
            for (int w=0; w<(str[q].length()/2); w++) {
                if (str[q][w]==str[q][str[q].length()-w-1]) continue;
                else { i++;}

            }
        if (i==0) {for (int w=0; w<str[q].length(); w++) {
                if (str[q][(str[q].length()-1)/2+1]!=str[q][w]){ swap(str[q][(str[q].length()-1)/2+1], str[q][w]);}
                else t++;
                }}
        if (t==str[q].length()) str[q]="-1";}
        for (int q=0; q<a; q++) cout<<str[q]<<endl;

}}


#include <iostream>
#include <string>

using namespace std;

int main() {
	int a, l, r, i=0; string str[10000];
	cin>> a;
	for (int q=0; q<a; q++)
	{
	    cin>>str[q];
	    if (str[q].length()==1||(str[q].length()==2&&str[q][0]==str[0][1])) {str[q]="-1";}
        else {
            r=str[q].length();
            for (int w=0; w<(str[q].length()/2); w++) {
                if (str[q][w]==str[q][str[q].length()-w-1]) continue;
                else { i++;}

            }
        if (i==0) {swap(str[q][str[q].length()/2-1],str[q][str[q].length()/2]);}}}
        for (int q=0; q<a; q++) cout<<str[q]<<endl;

}


#include <iostream>
#include <string>

using namespace std;

int main() {
	int a, l, r, i=0, t; string str[10000];
	cin>> a;
	for (int q=0; q<a; q++)
	{
	    t=0;
	    i=0;
	    cin>>str[q];
	    if (str[q].length()==1||(str[q].length()==2&&str[q][0]==str[0][1])) {str[q]="-1";}
        else {
            r=str[q].length();
            for (int w=0; w<(str[q].length()/2); w++) {
                if (str[q][w]==str[q][str[q].length()-w-1]) continue;
                else { i++;}

            }
        if (i==0) {for (int w=0; w<str[q].length(); w++) {
                if (str[q][(str[q].length()-1)/2+1]!=str[q][w]){ swap(str[q][(str[q].length()-1)/2+1], str[q][w]); break;}
               /* else if (str[q].length()==4&&i==0) swap (str[q][0], str[q][1]);*/
                else  t++;
                }}
        if (t==str[q].length()) str[q]="-1";}}
        for (int q=0; q<a; q++) cout<<str[q]<<endl;

}


#include <iostream>
#include <string>

using namespace std;

int main() {
	int a, l, r, i=0, t; string str[10000];
	cin>> a;
	for (int q=0; q<a; q++)
	{
	    t=0;
	    i=0;
	    cin>>str[q];
	    if (str[q].length()==1||(str[q].length()==2&&str[q][0]==str[0][1])) {str[q]="-1";}
        else {
            r=str[q].length();
            for (int w=0; w<(str[q].length()/2); w++) {
                if (str[q][w]==str[q][str[q].length()-w-1]) continue;
                else { i++;}
                cout<<i;

            }
        if (i==0) {for (int w=0; w<str[q].length(); w++) {
                if (str[q][(str[q].length()-1)/2+1]!=str[q][w]){ swap(str[q][(str[q].length()-1)/2+1], str[q][w]); break;}
               /* else if (str[q].length()==4&&i==0) swap (str[q][0], str[q][1]);*/
                else  t++;
                }}
        if (t==str[q].length()) str[q]="-1";}}
        for (int q=0; q<a; q++) cout<<str[q]<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int gi()
{
	char c; int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())x=(x<<1)+(x<<3)+c-'0';
	return x*f;
}
char s[1005];
int b[30];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("b.in","r",stdin);
#endif
	int t=gi();
	while(t--)
	{
		scanf("%s",s);
		memset(b,0,sizeof(b));
		char c=s[0]; bool flag=true;
		for(int i=0;s[i];i++)
		{
			b[s[i]-'a']++;
			if(s[i]!=c) flag=false;
		}
		if(flag)
		{
			puts("-1");
			continue;
		}
		for(int i=0;i<26;i++)
			for(int j=1;j<=b[i];j++) putchar(i+'a');
		puts("");
	}
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int n;
string s[105];
string cmp;

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
        cmp=s[i];
        reverse(cmp.begin(),cmp.end());
        if(cmp!=s[i])
            cout<<s[i]<<endl;
        else
           cout<<-1<<endl;
    }
    return 0;
}


#include <cstdio>
#include <iostream>
#include <stack>
#include <utility>
#include <algorithm>
#include <ctime>
#include <set>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dec(i,a,b) for(int i=(a);i>=(b);--i)
#define gc() getchar()
#define endll putchar('\n')
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef long double ld;
inline ll read(){
    char ch=gc();
    ll x=0,f=1;
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=-1;
        ch=gc();
    }
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=gc();
    }
    return x*f;
}
inline void print(ll k){
    if(k<0) k=-k,putchar('-');
    if(k>9) print(k/10);
    putchar(k%10+48);
}
inline void println(ll k){
    print(k);
    endll;
}
inline void printsp(ll k){
    print(k);
    putchar(' ');
}
bool is_pal(string a){
	if(a.size()==1) return true;
	rep(i,0,((a.size()/2)-1))  if(a[i]!=a[a.size()-i-1]) return false;
	return true;
}
bool is_samee(string a){
	rep(i,1,(a.size()-1)) if(a[i]!=a[i-1]) return false;
	return true;
}
int main(){
	int t=read();
	while(t--){
		string a;
		cin>>a;
		if(is_samee(a)) println(-1);
		else{
			while(is_pal(a)) random_shuffle(a.begin(),a.end());
			cout<<a<<endl;
		}
	}
}


#include<cstdio>
#include<cstring>
int b[27],s;char c[1002];
int main(){
	int T;scanf("%d",&T);for(;T--;){
	memset(b,0,sizeof b);s=0;
	scanf("%s",c);
	for(int i=0;c[i];i++)b[c[i]-96]++;
	for(int i=1;i<=26;i++)s+=b[i]>0;
	if(s<=1){puts("-1");continue;}
	for(int i=1;i<=26;i++)
	  for(;b[i]--;)putchar(i+96);
	puts("");
	}return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

bool huiwen(string x)
{
	string y = x;
	reverse(y.begin(), y.end());
	return y == x;
}

string s;

int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		cin >> s;
		if(!huiwen(s))
		{
			printf("%s", s.c_str);
		}
		else
		{
			sort(s.begin(), s.end());
			if(!huiwen(s))
			{
				printf("%s", s.c_str);
				continue;
			}
			else
			{
				while(next_permutation(s.begin(), s.end()))
				{
					if(!huiwen(s))
					{
						printf("%s", s.c_str);
						break;
					}
				}
			}
			printf("-1\n");
		}
	}
	return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main(){
	int t;
	cin >> t;
	while (t--){
		string s;
		cin >> s;
		int i = 0;
		int j = s.size() - 1;
		while (i != j && i < j){
			bool flg = 0;
			if (s[i] == s[j]){
				for (int p = i + 1; p < j; ++j){
					if (s[p] != s[i]){
						char tmp = s[p];
						s[p] = s[i];
						s[i] = tmp;
						flg = 1;
						break;
					}
				}
				if (flg) break;
				else{
					++i;
					--j;
				}
			}
			else break;
		}
		if (i == j || i > j) cout << -1 << endl;
		else		cout << s  << endl;
	}
}


#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n--){
		bool c=0;
		string a;
		cin>>a;
		for(int i=0;i<a.size()/2;i++){
			if(a[i]!=a[a.size()-i-1]){
				cout<<a<<endl;
				c=1;
				break;
			}
		}
		if(!c){
			for(int i=0;i<a.size();i++){
				if(a[i]!=a[0]){
					swap(a[i],a[0]);
					cout<<a<<endl;
					c=1;
					break;
				}
			}
			if(!c)cout<<-1<<endl;
		}
	}
}


#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
string s;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string e;
		cin>>s;
		sort(s.begin(),s.end());
		e=s;
		reverse(e.begin(),e.end());
		if(s==e) cout<<-1<<endl;
		else cout<<e<<endl;
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char s[1005];
int main()
{
 int t;
 scanf("%d",&t);
 while(t--)
 {
  bool flag=true;
  scanf("%s",s);
  int len=strlen(s);
  sort(s,s+len);
  for(int i=0;i<len/2;i++)
   if(s[i]!=s[len-i-1])//判断排序后的串是否是回文串
   {
    flag=false;
    break;
   }
  if(flag)puts("-1");
  else puts(s);
 }
 return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

bool huiwen(string x)
{
	string y = x;
	reverse(y.begin(), y.end());
	return y == x;
}

string s;

int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		cin >> s;
		if(!huiwen(s))
		{
			printf("%s", s.c_str());
		}
		else
		{
			sort(s.begin(), s.end());
			if(!huiwen(s))
			{
				printf("%s", s.c_str());
				continue;
			}
			else
			{
				while(next_permutation(s.begin(), s.end()))
				{
					if(!huiwen(s))
					{
						printf("%s", s.c_str());
						break;
					}
				}
			}
			printf("-1\n");
		}
	}
	return 0;
}


#include <cstdio>
#include <iostrean>
#include <algorithm>
#include <cstring>
using namespace std;

bool huiwen(string x)
{
	string y = x;
	reverse(y.begin(), y.end());
	return y == x;
}

string s;

int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		cin >> s;
		if(!huiwen(s))
		{
			printf("%s", &s.c_str);
		}
		else
		{
			sort(s.begin(), s.end());
			if(!huiwen(s))
			{
				printf("%s", &s.c_str);
				continue;
			}
			else
			{
				while(next_permutation(s.begin(), s.end()))
				{
					if(!huiwen(s))
					{
						printf("%s", &s.c_str);
						break;
					}
				}
			}
			printf("-1\n");
		}
	}
	return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int t,i,j,b[30],s;
	string a;
	cin>>t;
	while(t--)
	{
		memset(b,0,sizeof(b));
		cin>>a;
		s=0;
		for(i=0;i<a.size();i++)
			b[a[i]-'a'+1]++;
		for(i=1;i<=26;i++)
			if(b[i]!=0)
				s++;
		if(s==1)
		{
			cout<<-1<<endl;
			continue;
		}
		for(i=1;i<=26;i++)
		{
			if(b[i]!=0)
				for(j=1;j<=b[i];j++)
					cout<<(char)(i+'a'-1);
		}
		cout<<endl;
	}
	return 0;
}


#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
char s[1005];
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		scanf("%s",s);
		int n;
		for(n=0;s[n];n++);
		sort(s,s+n);
		if(s[0]!=s[n-1])printf("%s\n",s);
		else printf("-1\n");
	}
	return 0;
}


#include<cstdio>
#include<cstring>
char word[1005],word2[1005];
int flag=0;
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        memset(word,0,sizeof(word));
        memset(word2,0,sizeof(word2));
        flag=0;
        scanf("%s",word);
        int lo=strlen(word);
        for(int i=0;i<lo;++i)
            word2[lo-i-1]=word[i];
        if(lo==1)
        {
            printf("-1\n");
            continue;
        }
        if(strcmp(word,word2)==0)
        {
            for(int i=0;i<lo-2;++i)
            {
                if(word[i]!=word[i+1])
                {
                    flag=1;
                    char a=word[i];
                    word[i]=word[i+1];
                    word[i+1]=a;
                    printf("%s\n",word);
                    break;
                }
            }
            if(flag==0)
                printf("-1\n");
        }
        else
        {
            printf("%s\n",word);
        }
    }
}


/*بسم الله الرحمن الرحيم*/
/*“Dengan menyebut nama Allah yang Maha Pengasih lagi Maha Penyayang”*/
/*“In the name of Allah, Most Gracious, Most Merciful”*/
/********************************************************************************************************\__
                                                                                |
        author  :   Althafa Dhia Syauqi   ||    email   :    daltafa@gmail.com                              ||
        SMAN 10 Samarinda, Kalimantan Timur.                                                    ||
                                                                                ||
/********************************************************************************************************/
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep_k(i,n) for(int x=i;x<n;x++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_n(i,n) for(int i=1;i<=(n);i++)
#define rep_all(k) for(auto x:k)
#define endl '\n'
#define mod 1e9+7
#define pb push_back
#define READ(f)         freopen(f, "r", stdin)
#define WRITE(f)        freopen(f, "w", stdout)
#define maxSort         sort(all(v),greater<int>())
#define rSort           sort(v.rbegin(),v.rend())
#define FOREACH(i,c) for (typeof((c).end()) i = (c).begin(); i != (c).end(); ++i)
#define RESET(c,v) memset(c, v, sizeof(c))
#define sqr(x)          ((x)*(x))
#define qube(x)         ((x)*(x)*(x))
using namespace std;
void optimization()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
string a;
bool checkPalindrome(string inputString) {
    if (inputString == string(inputString.rbegin(), inputString.rend())) {
        return true;
    }else{
        return false;
    }
}

ll t;
int main()
{
	optimization();
	cin >> t;
	rep(i,t){
    cin >> a;
    if(checkPalindrome(a))
    {
        if(a.length()==2||a.length()==1)
           cout<<"-1"<<endl;
            else
        {

            random_shuffle(a.begin(),a.end());
            cout <<a<<endl;
        }
    }else
    {
        cout << a<<endl;
    }}
	return 0;
}


/*بسم الله الرحمن الرحيم*/
/*“Dengan menyebut nama Allah yang Maha Pengasih lagi Maha Penyayang”*/
/*“In the name of Allah, Most Gracious, Most Merciful”*/
/********************************************************************************************************\__
                                                                                |
        author  :   Althafa Dhia Syauqi   ||    email   :    daltafa@gmail.com                              ||
        SMAN 10 Samarinda, Kalimantan Timur.                                                    ||
                                                                                ||
/********************************************************************************************************/
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep_k(i,n) for(int x=i;x<n;x++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_n(i,n) for(int i=1;i<=(n);i++)
#define rep_all(k) for(auto x:k)
#define endl '\n'
#define mod 1e9+7
#define pb push_back
#define READ(f)         freopen(f, "r", stdin)
#define WRITE(f)        freopen(f, "w", stdout)
#define maxSort         sort(all(v),greater<int>())
#define rSort           sort(v.rbegin(),v.rend())
#define FOREACH(i,c) for (typeof((c).end()) i = (c).begin(); i != (c).end(); ++i)
#define RESET(c,v) memset(c, v, sizeof(c))
#define sqr(x)          ((x)*(x))
#define qube(x)         ((x)*(x)*(x))
using namespace std;
void optimization()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
string a;
bool checkPalindrome(string inputString) {
    if (inputString == string(inputString.rbegin(), inputString.rend())) {
        return true;
    }else{
        return false;
    }
}
void scrambleString(std::string& str)
{
    int x = str.length();
    for(int y = x; y > 0; y--)
    {
        int pos = rand()%x;
        char tmp = str[y-1];
        str[y-1] = str[pos];
        str[pos] = tmp;
    }
}
ll t;
int main()
{
	optimization();
	cin >> t;
	rep(i,t){
    cin >> a;
    if(checkPalindrome(a))
    {
        if(a.length()==2)
           cout<<"-1"<<endl;
            else
        {
            scrambleString(a);
            cout <<a<<endl;
        }
    }else
    {
        cout << a<<endl;
    }}
	return 0;
}


/*بسم الله الرحمن الرحيم*/
/*“Dengan menyebut nama Allah yang Maha Pengasih lagi Maha Penyayang”*/
/*“In the name of Allah, Most Gracious, Most Merciful”*/
/********************************************************************************************************\__
                                                                                |
        author  :   Althafa Dhia Syauqi   ||    email   :    daltafa@gmail.com                              ||
        SMAN 10 Samarinda, Kalimantan Timur.                                                    ||
                                                                                ||
/********************************************************************************************************/
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep_k(i,n) for(int x=i;x<n;x++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_n(i,n) for(int i=1;i<=(n);i++)
#define rep_all(k) for(auto x:k)
#define endl '\n'
#define mod 1e9+7
#define pb push_back
#define READ(f)         freopen(f, "r", stdin)
#define WRITE(f)        freopen(f, "w", stdout)
#define maxSort         sort(all(v),greater<int>())
#define rSort           sort(v.rbegin(),v.rend())
#define FOREACH(i,c) for (typeof((c).end()) i = (c).begin(); i != (c).end(); ++i)
#define RESET(c,v) memset(c, v, sizeof(c))
#define sqr(x)          ((x)*(x))
#define qube(x)         ((x)*(x)*(x))
using namespace std;
void optimization()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
string a;
bool checkPalindrome(string inputString) {
    if (inputString == string(inputString.rbegin(), inputString.rend())) {
        return true;
    }else{
        return false;
    }
}

ll t;
bool cek()
{
    ll temp=0;
    rep(i,a.length())
    {
        if(a[i]!=a[i-1])
            temp++;
    }
    if(temp!=1)
        return 0;
        else
            return 1;
}
int main()
{
	optimization();
	cin >> t;
	rep(i,t){
    cin >> a;
    if(checkPalindrome(a))
    {
        if(a.length()==2||a.length()==1||cek())
           cout<<"-1"<<endl;
            else
        {

            random_shuffle(a.begin(),a.end());
            cout <<a<<endl;
        }
    }else
    {
        cout << a<<endl;
    }}
	return 0;
}


/*بسم الله الرحمن الرحيم*/
/*“Dengan menyebut nama Allah yang Maha Pengasih lagi Maha Penyayang”*/
/*“In the name of Allah, Most Gracious, Most Merciful”*/
/********************************************************************************************************\__
                                                                                |
        author  :   Althafa Dhia Syauqi   ||    email   :    daltafa@gmail.com                              ||
        SMAN 10 Samarinda, Kalimantan Timur.                                                    ||
                                                                                ||
/********************************************************************************************************/
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep_k(i,n) for(int x=i;x<n;x++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_n(i,n) for(int i=1;i<=(n);i++)
#define rep_all(k) for(auto x:k)
#define endl '\n'
#define mod 1e9+7
#define pb push_back
#define READ(f)         freopen(f, "r", stdin)
#define WRITE(f)        freopen(f, "w", stdout)
#define maxSort         sort(all(v),greater<int>())
#define rSort           sort(v.rbegin(),v.rend())
#define FOREACH(i,c) for (typeof((c).end()) i = (c).begin(); i != (c).end(); ++i)
#define RESET(c,v) memset(c, v, sizeof(c))
#define sqr(x)          ((x)*(x))
#define qube(x)         ((x)*(x)*(x))
using namespace std;
void optimization()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
string a;
bool checkPalindrome(string inputString) {
    if (inputString == string(inputString.rbegin(), inputString.rend())) {
        return true;
    }else{
        return false;
    }
}
void scrambleString(std::string& str)
{
    int k = str.length();
    for(int y = k; y > 0; y--)
    {
        int pos = rand()%k;
        char tmp = str[y-1];
        str[y-1] = str[pos];
        str[pos] = tmp;
    }
}
ll t;
int main()
{
	optimization();
	cin >> t;
	rep(i,t){
    cin >> a;
    if(checkPalindrome(a))
    {
        if(a.length()==2||a.length()==1)
           cout<<"-1"<<endl;
            else
        {
            scrambleString(a);
            cout <<a<<endl;
        }
    }else
    {
        cout << a<<endl;
    }}
	return 0;
}


/*بسم الله الرحمن الرحيم*/
/*“Dengan menyebut nama Allah yang Maha Pengasih lagi Maha Penyayang”*/
/*“In the name of Allah, Most Gracious, Most Merciful”*/
/********************************************************************************************************\__
                                                                                |
        author  :   Althafa Dhia Syauqi   ||    email   :    daltafa@gmail.com                              ||
        SMAN 10 Samarinda, Kalimantan Timur.                                                    ||
                                                                                ||
/********************************************************************************************************/
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep_k(i,n) for(int x=i;x<n;x++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_n(i,n) for(int i=1;i<=(n);i++)
#define rep_all(k) for(auto x:k)
#define endl '\n'
#define mod 1e9+7
#define pb push_back
#define READ(f)         freopen(f, "r", stdin)
#define WRITE(f)        freopen(f, "w", stdout)
#define maxSort         sort(all(v),greater<int>())
#define rSort           sort(v.rbegin(),v.rend())
#define FOREACH(i,c) for (typeof((c).end()) i = (c).begin(); i != (c).end(); ++i)
#define RESET(c,v) memset(c, v, sizeof(c))
#define sqr(x)          ((x)*(x))
#define qube(x)         ((x)*(x)*(x))
using namespace std;
void optimization()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
string a;
bool checkPalindrome(string inputString) {
    if (inputString == string(inputString.rbegin(), inputString.rend())) {
        return true;
    }else{
        return false;
    }
}

ll t;
bool cek()
{
    string l=a,p=a;
    random_shuffle(a.begin(),a.end());
    random_shuffle(a.begin(),a.end());
    if(p==l)
        return 1;
    else
        return 0;
}
int main()
{
	optimization();
	cin >> t;
	rep(i,t){
    cin >> a;
    if(checkPalindrome(a))
    {
        if(a.length()==2||a.length()==1||cek())
           cout<<"-1"<<endl;
            else
        {

            random_shuffle(a.begin(),a.end());
            cout <<a<<endl;
        }
    }else
    {
        cout << a<<endl;
    }}
	return 0;
}