#include <bits/stdc++.h>
using namespace std;
int isPalindrome(string s) {
  long long int n = s.length();
  for (long long int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - 1 - i]) {
      return 0;
    }
  }
  return 1;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    if (s.length() == 1) {
      cout << "-1" << endl;
      continue;
    }
    long long int i, n = s.length();
    if (!isPalindrome(s)) {
      cout << s << endl;
    } else {
      long long int flag = 0;
      char a = s[0];
      for (i = 1; i < n; i++) {
        if (s[i] != a) {
          swap(s[0], s[i]);
          flag = 1;
          break;
        }
      }
      if (flag) {
        cout << s << endl;
      } else {
        cout << "-1" << endl;
      }
    }
  }
}
