#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int z;
  cin >> z;
  while (z--) {
    string a;
    cin >> a;
    sort(a.begin(), a.end());
    bool cek = false;
    for (int q = 0, w = a.size() - 1; q <= w; q++, w--) {
      if (a[q] != a[w]) cek = true;
    }
    if (cek == false)
      cout << -1 << endl;
    else
      cout << a << endl;
  }
}
