#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int flag = 0;
    string s;
    cin >> s;
    if (s.length() <= 1) {
      cout << "-1" << endl;
    } else {
      for (int i = 0; i < s.length() - 1; i++) {
        if (s[i] != s[i + 1]) {
          flag = 1;
          break;
        }
      }
      if (flag == 0) {
        cout << "-1" << endl;
      } else {
        int i = 0, j = s.length() - 1;
        while (i != j) {
          if (s[i] == s[j]) {
            i++;
            j--;
          } else {
            flag = 2;
            break;
          }
          if ((i - 1) == j) {
            break;
          }
        }
        if (flag == 2) {
          cout << s << endl;
        } else {
          sort(s.begin(), s.end());
          cout << s << endl;
        }
      }
    }
  }
}
