#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 5;
const long long MOD = 1e9 + 7;
const double EPS = 1e-8;
set<char> st;
int main() {
  int t;
  string str;
  cin >> t;
  while (t--) {
    cin >> str;
    st.clear();
    for (auto i : str) st.insert(i);
    if (st.size() == 1) {
      cout << -1 << endl;
      continue;
    }
    sort(str.begin(), str.end());
    cout << str << endl;
  }
  return 0;
}
