#include <bits/stdc++.h>
using namespace std;
int N = 1000005;
vector<vector<long long int>> tree(N, vector<long long int>());
vector<bool> visited(N, 0L);
vector<long long int> p(N, 0L);
vector<long long int> anc_p(N, 0L);
vector<long long int> sbt_sum(N, 0L);
void solve() {
  string s;
  cin >> s;
  map<char, int> make_pair;
  for (long long int i = 0, almo5t = s.size(); i < almo5t; ++i) {
    make_pair[s[i]]++;
  }
  string sol = "";
  if (make_pair.size() == 1) {
    cout << "-1";
  } else {
    for (auto l : make_pair) {
      int sz = l.second;
      while (sz--) {
        cout << l.first;
      }
    }
  }
  cout << "\n";
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
