#include <bits/stdc++.h>   using namespace std;   char s[10010];   int main() {     int n;     cin >> n;     while (n--) {       string a;       cin >> a;       for (int i = 0; i < a.size(); i++) {         s[i] = a[i];       }       sort(s, s + a.size());       if (s[0] == s[a.size() - 1]) {         cout << -1 << endl;       } else {         for (int i = 0; i < a.size(); i++) {           cout << s[i];         }         cout << endl;       }     }   }   