#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    string str;
    cin >> str;
    if (str.length() == 1) {
      cout << "-1" << endl;
      continue;
    }
    char ch = str[0];
    int flag = 0;
    int l = str.length();
    for (int i = 0; i < l; i++) {
      if (str[i] != ch) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      cout << "-1" << endl;
      continue;
    }
    int pg = 0;
    for (int i = 0; i < l; i++) {
      if (str[i] != str[l - 1 - i]) {
        pg = 1;
        cout << str << endl;
        break;
      }
    }
    if (pg == 0) {
      char ch = str[0];
      string btr = "";
      for (int i = 1; i < l; i++)
        if (str[i] != ch) {
          if (i != 1)
            btr = str[i] + str.substr(1, i - 1) + ch + str.substr(i + 1);
          if (i == 1) btr = str[1] + str.substr(0, 1) + str.substr(i + 1);
          cout << btr << endl;
          break;
        }
    }
  }
}
