#include <bits/stdc++.h>
using namespace std;
vector<int> read_int_array(int n) {
  vector<int> arr;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    arr.push_back(temp);
  }
  return arr;
}
vector<long long int> read_llint_array(int n) {
  vector<long long int> arr;
  for (int i = 0; i < n; i++) {
    long long int temp;
    cin >> temp;
    arr.push_back(temp);
  }
  return arr;
}
int main() {
  int t;
  cin >> t;
  for (int _ = 0; _ < t; _++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s.front() == s.back()) {
      cout << "-1" << endl;
    } else {
      cout << s << endl;
    }
  }
  return 0;
}
