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