#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int c = 0;
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    for (int i = 0; i < s.size() - 1; i++) {
      if (s[i] != s[i + 1]) {
        c = 1;
        break;
      }
    }
    if (c == 1)
      cout << s << "\n";
    else
      cout << "-1\n";
  }
  return 0;
}
