#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int tst;
  string s;
  cin >> tst;
  while (tst--) {
    bool flag = 0;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] != s[0]) {
        flag = 1;
        break;
      }
    }
    if (!flag)
      cout << -1 << endl;
    else {
      sort(s.begin(), s.end());
      cout << s << endl;
    }
  }
  return 0;
}
