#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == s.back()) {
    cout << "-1" << endl;
  } else {
    cout << s << endl;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
