#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s.back())
      cout << -1 << endl;
    else
      cout << s << endl;
  }
}
