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