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