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