#include <bits/stdc++.h>
using namespace std;
void swap(string& s, int i) {
  char temp = s[0];
  s[0] = s[i];
  s[i] = temp;
}
bool isPalindrome(string s) {
  int i = 0, j = s.size() - 1;
  while (i < j) {
    if (s[i] != s[j]) {
      return false;
    }
    i++;
    j--;
  }
  return true;
}
void solve() {
  string s;
  cin >> s;
  if (isPalindrome(s)) {
    for (int i = 1; i < s.size(); i++) {
      if (s[0] != s[i]) {
        swap(s, i);
        cout << s << endl;
        return;
      }
    }
    cout << -1 << endl;
  } else {
    cout << s << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
