#include <bits/stdc++.h>
using namespace std;
const int mx = 1000500;
set<char> st;
int main() {
  int n;
  cin >> n;
  while (n--) {
    string a, b;
    cin >> a;
    int l = a.length();
    b = a;
    reverse(b.begin(), b.end());
    sort(a.begin(), a.end());
    if (a[0] == a[l - 1])
      cout << "-1" << endl;
    else
      cout << a << endl;
  }
}
