#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int n = s.length(), flag = 1;
    for (int i = 0; i <= n - 1; i++) {
      if (s[i] != s[n - i - 1]) flag = 0;
    }
    if (flag == 0) {
      cout << s << '\n';
      continue;
    }
    for (int i = 1; i <= s.length() - 1; i++)
      if (s[i] != s[0]) {
        swap(s[0], s[i]);
        flag = 0;
        break;
      }
    if (flag == 1) {
      cout << -1 << '\n';
      continue;
    }
    cout << s << endl;
  }
}
