#include <bits/stdc++.h>
using namespace std;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int& n, int b) { n |= two(b); }
inline void unset_bit(int& n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) {
  int res = 0;
  while (n && ++res) n -= n & (-n);
  return res;
}
const double pi = acos(-1);
const int oo = 0x3f3f3f3f;
int cmp(double x, double y = 0, double tol = 1e-9) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
const int MAX_N = 2234506;
int main() {
  int TC;
  scanf("%d", &TC);
  while (TC--) {
    string s;
    cin >> s;
    vector<int> V(26);
    for (int i = 0; i < int(s.length()); i++) V[s[i] - 'a']++;
    bool flag = false;
    for (int i = 0; i < int(26); i++)
      if (V[i] == s.length()) {
        printf("%d\n", -1);
        flag = true;
      }
    if (flag) continue;
    for (int i = 0; i < int(26); i++)
      for (int j = 0; j < int(V[i]); j++) printf("%c", 'a' + i);
    printf("\n");
  }
  return 0;
}
