#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    string ns = s;
    sort(s.begin(), s.end());
    if (s == ns && s[0] == ns[ns.size() - 1]) {
      cout << -1 << "\n";
      continue;
    }
    cout << s << "\n";
  }
}
