#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  string second;
  cin >> t;
  int n;
  string k;
  while (t--) {
    cin >> second;
    sort(((second).begin()), ((second).end()));
    k = second;
    reverse(((k).begin()), ((k).end()));
    if (k == second)
      cout << "-1";
    else
      cout << second;
    cout << endl;
  }
  return 0;
}
