#include <bits/stdc++.h>
using namespace std;
int dirx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int diry[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
bool palin(string s) {
  for (long long i = 0; i < s.length(); ++i) {
    if (s[i] != s[s.length() - i - 1]) return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    if (!palin(s))
      cout << s << endl;
    else {
      sort(s.begin(), s.end());
      if (palin(s))
        cout << "-1\n";
      else
        cout << s << endl;
    }
  }
}
