#include <bits/stdc++.h>
using namespace std;
int tt;
string input;
int main() {
  cin >> tt;
  for (int qq = 1; qq <= tt; qq++) {
    cin >> input;
    int count[250] = {};
    for (char c : input) count[c - 'a']++;
    int diff = 0;
    for (int i = 0; i < 250; i++) {
      if (count[i] > 0) diff++;
    }
    if (diff == 1)
      cout << "-1" << endl;
    else {
      sort(input.begin(), input.end());
      cout << input << endl;
    }
  }
  return 0;
}
