#include <bits/stdc++.h>
using namespace std;
int x4[] = {0, 0, 1, -1};
int y4[] = {1, -1, 0, 0};
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  string x;
  while (t--) {
    cin >> x;
    set<char> niloy;
    for (int i = 0; i < x.length(); ++i) {
      niloy.insert(x[i]);
    }
    if (niloy.size() == 1) {
      cout << -1 << "\n";
    } else {
      sort(x.begin(), x.end());
      cout << x << "\n";
    }
  }
  return 0;
}
