#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 10;
const long long MAX1 = 1e4 + 10;
const int INF = 1e9;
const long long MOD = 1e9 + 7;
double eps = 1e-7;
long long ciel(long long a, long long b) {
  if (b == 0) return INF;
  return ((a + b - 1) / b);
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    string x, y;
    cin >> x;
    y = x;
    reverse(&x[0], &x[x.size()]);
    if (y == x) {
      char r = x[0];
      int r1;
      int sz = x.size();
      bool tr = 0;
      for (int i = 0; i < sz; i++) {
        if (x[i] != r) {
          r1 = i;
          tr = 1;
          break;
        }
      }
      if (!tr) {
        cout << -1 << "\n";
      } else {
        x[0] = x[r1];
        x[r1] = r;
        cout << x << "\n";
      }
    } else {
      cout << y << "\n";
    }
  }
}
