#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll fpow(ll b, ll p) {
  if (p == 0) return 1;
  ll h = fpow(b, p / 2);
  if (p % 2) return h * b % (ll)(1e9 + 7) * h % (ll)(1e9 + 7);
  return h * h % (ll)(1e9 + 7);
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  string s;
  while (n--) {
    cin >> s;
    sort(s.begin(), s.end());
    bool f = true;
    for (ll i = 0; i <= ((ll)s.size()) - 1; i++) {
      if (s[i] != s[((ll)s.size()) - i - 1]) {
        f = false;
        break;
      }
    }
    if (!f)
      cout << s << "\n";
    else
      cout << "-1\n";
  }
  return 0;
}
