#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int arr[27] = {0};
    string s;
    cin >> s;
    bool f = true;
    int temp = -1;
    for (int i = 0; i < s.size(); i++) {
      arr[s[i] - 'a']++;
      if (temp == -1) {
        temp = s[i] - 'a';
      } else {
        if (temp != s[i] - 'a') {
          f = false;
        }
      }
    }
    if (f) {
      cout << -1 << endl;
    } else {
      for (int i = 0; i < 26; i++) {
        while (arr[i]) {
          printf("%c", i + 'a');
          arr[i]--;
        }
      }
      printf("\n");
    }
  }
  return 0;
}
