#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const long double pi = acos((ld)-1.0);
const double eps = (double)1e-9;
const int inf = (int)1e9 + 7;
bool vovel(char ch) {
  return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ||
          ch == 'y');
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    set<char> st;
    for (int i = 0; i < s.size(); i++) {
      st.insert(s[i]);
    }
    if (st.size() == 1) {
      cout << -1 << '\n';
      continue;
    }
    sort(s.begin(), s.end());
    cout << s << '\n';
  }
  return 0;
}
