#include <bits/stdc++.h>
using lint = long long;
using ld = long double;
template <class T>
using numr = std::numeric_limits<T>;
struct input_t {
  template <class T>
  operator T() {
    T t;
    std::cin >> t;
    return t;
  }
} input;
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);
  lint q = input;
  while (q--) {
    std::string s = input;
    if (s == std::string(s.length(), s.front())) {
      std::cout << -1 << '\n';
      continue;
    }
    std::sort(std::begin(s), std::end(s));
    std::cout << s << '\n';
  }
}
