#include <bits/stdc++.h>
using namespace std;
void result() {
  string s;
  cin >> s;
  long long cnt = 0;
  for (long long i = 0, j = s.size() - 1; i < j; i++, j--) {
    if (s[i] != s[j]) {
      cout << s << endl;
      cnt = 1;
      break;
    } else {
      swap(s[j], s[j - 1]);
      if (s[i] != s[j]) {
        cout << s << endl;
        cnt = 1;
        break;
      }
    }
  }
  if (cnt == 0) cout << -1 << endl;
}
int main() {
  long long t;
  cin >> t;
  while (t--) {
    result();
  }
}
