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