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