#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int c = 0;
    string str;
    cin >> str;
    int length = str.size();
    for (int i = 0; i < (length / 2); i++) {
      if (str[i] != str[length - i - 1]) {
        c++;
        break;
      }
    }
    if (c != 0)
      cout << str << "\n";
    else {
      c = 1;
      for (int i = 0; i < length - 1; i++) {
        if (str[i] == str[i + 1]) c++;
      }
      if (length == 1)
        cout << "-1\n";
      else if (c == length)
        cout << "-1\n";
      else {
        for (int i = 0; i < length; i++) {
          if (str[i] != str[i + 1]) {
            char ch = str[i + 1];
            str[i + 1] = str[i];
            str[i] = ch;
            break;
          }
        }
        cout << str << "\n";
        ;
      }
    }
  }
}
