#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    n = s.length();
    sort(s.begin(), s.end());
    if (s[0] == s[n - 1] || n == 1)
      cout << "-1" << endl;
    else
      cout << s << endl;
  }
}
