#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    string s;
    cin >> s;
    map<char, int> ma;
    sort(s.begin(), s.end());
    for (auto x : s) ma[x]++;
    if (ma.begin()->second == s.size())
      cout << -1 << "\n";
    else
      cout << s << "\n";
  }
  return 0;
}
