#include <bits/stdc++.h>
using namespace std;
int arr[123];
int main() {
  int t;
  cin >> t;
  string str;
  while (t--) {
    cin >> str;
    bool tf = false;
    int cnt = 0;
    int len = str.length();
    for (int i = 0; i < len; i++) {
      arr[str[i]]++;
    }
    for (int i = 97; i < 123; i++) {
      if (arr[i] > 0) cnt += arr[i];
    }
    for (int i = 97; i < 123; i++) {
      if (arr[i] == cnt) {
        tf = true;
        break;
      }
    }
    if (tf)
      cout << -1 << endl;
    else {
      for (int i = 97; i < 123; i++) {
        if (arr[i] > 0) {
          for (int j = 0; j < arr[i]; j++) {
            cout << (char)i;
          }
        }
      }
      cout << endl;
    }
    for (int i = 97; i < 123; i++) {
      arr[i] = 0;
    }
  }
}
