#include <bits/stdc++.h>
using namespace std;
string s;
bool q;
int t, ans, leng, len;
bool isPa(string s) {
  leng = s.size() / 2;
  int i = 0, j = s.size() - 1;
  while (i < leng && j > leng) {
    if (s[i] == s[j])
      q = 1;
    else {
      q = 0;
      break;
    }
    i++;
    j--;
  }
  if (q)
    return 1;
  else
    return 0;
}
int main() {
  cin >> t;
  while (t--) {
    set<char> st;
    cin >> s;
    for (int i = 0; i < s.size(); i++) st.insert(s[i]);
    if (st.size() == 1)
      cout << -1 << endl;
    else if (isPa(s)) {
      len = s.size() / 2;
      for (int i = s.size() - 1; i > len; i--) {
        if (s[len] != s[i]) {
          swap(s[len], s[i]);
          break;
        }
      }
      for (int i = 0; i < s.size(); i++) cout << s[i];
      cout << endl;
    } else {
      for (int i = 0; i < s.size(); i++) cout << s[i];
      cout << endl;
    }
  }
  return 0;
}
