#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    string s, rs;
    cin >> s;
    map<char, long long> mp;
    for (int i = 0; i < s.size(); i++) mp[s[i]]++;
    if (mp.size() == 1) {
      cout << "-1" << endl;
      continue;
    }
    rs = s;
    reverse(rs.begin(), rs.end());
    if (rs == s) {
      int m = s.size() / 2;
      for (int j = 0; j <= m; j++) {
        if (s[0] != s[j]) {
          swap(s[0], s[j]);
          break;
        }
      }
    }
    cout << s << endl;
  }
  return 0;
}
