#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string str;
    cin >> str;
    int len = str.length();
    int count = 0;
    for (int i = 1; len > i; i++) {
      if (str[i] == str[i - 1])
        count++;
      else
        break;
    }
    if (count == len - 1) {
      cout << -1 << endl;
      continue;
    }
    sort(str.begin(), str.end());
    cout << str << endl;
  }
}
