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