#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MAX = 10000000000000;
const ll mod = 1e9 + 7;
void solve() {
  string s1;
  cin >> s1;
  if (count(s1.begin(), s1.end(), s1[0]) == s1.size()) {
    cout << -1 << endl;
    return;
  }
  sort(s1.begin(), s1.end());
  cout << s1 << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
