#include <bits/stdc++.h>
using namespace std;
int lim = 1e6;
int inf = 1e9 + 7;
bool ispal(string s) {
  int n = s.size();
  bool ans = true;
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - i - 1]) {
      ans = false;
      break;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    if (!ispal(s)) {
      cout << s << '\n';
      ;
    } else {
      char x = s[0];
      bool check = false;
      string ans = s;
      for (int i = 1; i < s.size(); i++) {
        if (x != s[i]) {
          check = true;
          ans[0] = ans[i];
          ans[i] = x;
          break;
        }
      }
      if (check) {
        cout << ans << '\n';
        ;
      } else {
        cout << -1 << '\n';
        ;
      }
    }
  }
}
