#include <bits/stdc++.h>
using namespace std;
bool P(string x) {
  int i = 0, j = x.size() - 1;
  while (i <= j) {
    if (x[i] != x[j]) return false;
    i++;
    j--;
  }
  return true;
}
int main() {
  int t;
  string x;
  cin >> t;
  while (t--) {
    cin >> x;
    int flag = 0;
    for (int i = 0; i < x.size(); i++)
      if (x[0] != x[i]) {
        flag = 1;
        break;
      }
    if (flag == 0) {
      cout << -1 << endl;
    } else {
      while (P(x)) {
        random_shuffle(x.begin(), x.end());
      }
      cout << x << endl;
    }
  }
}
