#include <bits/stdc++.h>
using namespace std;
bool isAllSimilar(string s, int l) {
  bool result = true;
  for (int i = 0; i < l && result; i++) {
    if (s[0] != s[l - i - 1]) result = false;
  }
  return result;
}
string swapPalindrom(string s, int l) {
  bool isswap = false;
  for (int i = 0; i < l && !isswap; i++) {
    if (s[0] != s[l - i - 1]) {
      swap(s[0], s[l - i - 1]);
      isswap = true;
    }
  }
  if (!isswap) {
    return "-1";
  }
  return s;
}
int main() {
  int t, l = 0;
  bool b = true;
  string s;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> s;
    l = s.length();
    if (l == 1) {
      cout << -1 << endl;
      continue;
    }
    if (isAllSimilar(s, l)) {
      cout << -1 << endl;
      continue;
    }
    for (int j = 0; j < l / 2 && b; ++j) {
      if (s[j] != s[l - j - 1]) {
        b = true;
      } else
        b = false;
    }
    if (!b) {
      s = swapPalindrom(s, l);
      if (s != "-1")
        cout << s << endl;
      else
        cout << -1 << endl;
    } else
      cout << s << endl;
    b = true;
  }
  return 0;
}
