#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int count[26] = {0};
    for (int i = 0; i < s.length(); i++) {
      count[(int)s[i] - 97]++;
    }
    int c = 0;
    for (int i = 0; i < 26; i++) {
      if (count[i] != 0) c++;
    }
    if (c == 1) {
      cout << -1 << endl;
    } else {
      for (int i = 0; i < 26; i++) {
        for (int j = 0; j < count[i]; j++) {
          cout << (char)(97 + i);
        }
      }
      cout << endl;
    }
  }
}
