#include <bits/stdc++.h>
using namespace std;
const int dmax = 1e3 + 5;
int T, o, l;
char sir[dmax];
int fr[30];
bool Check() {
  int i, j;
  for (i = 0; i < l; i++) {
    if (sir[i] != sir[0]) {
      return true;
    }
  }
  return false;
}
int main() {
  int i, j;
  cin >> T;
  for (i = 1; i <= T; i++) {
    cin >> sir;
    l = strlen(sir);
    if (Check()) {
      sort(sir, sir + l);
      cout << sir << '\n';
    } else
      cout << "-1\n";
  }
  return 0;
}
