#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  long long cnt[27];
  while (t--) {
    string s;
    cin >> s;
    for (long long i = 0; i < 27; i++) cnt[i] = 0;
    for (long long i = 0; i < s.length(); i++) cnt[s[i] - 'a']++;
    long long check = 0;
    for (long long i = 0; i < 27; i++) {
      if (cnt[i] != 0) check++;
    }
    sort(s.begin(), s.end());
    if (check != 1)
      cout << s << endl;
    else
      cout << -1 << endl;
    ;
  }
}
