#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    string x = s;
    sort(x.begin(), x.end());
    int p = true;
    int j = s.length() - 1;
    for (int i = 0; s[i]; i++) {
      if (s[i] != s[j]) {
        p = false;
        break;
      }
      j--;
    }
    for (int i = 0; s[i] && p; i++) {
      if (s[i] != x[i]) {
        p = false;
        break;
      }
    }
    if (p == true)
      cout << -1 << endl;
    else
      cout << x << endl;
  }
  return 0;
}
