#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 5;
void solve() {
  string s;
  cin >> s;
  long long diff = 0;
  for (long long i = 1; i < (long long)s.size(); i++) {
    if (s[i] != s[i - 1]) diff = 1;
  }
  sort((s).begin(), (s).end());
  if (diff)
    cout << s << endl;
  else
    cout << -1 << endl;
}
signed main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
