#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, i;
  string str;
  cin >> t;
  for (i = 0; i < t; i++) {
    cin >> str;
    int length = str.length();
    int j;
    bool check_eq = true, check_pal = true;
    int change_index = 0;
    for (j = 1; j < length; j++) {
      if (str[j] != str[j - 1]) {
        check_eq = false;
        change_index = j;
        break;
      }
    }
    if (check_eq) {
      cout << "-1\n";
      continue;
    }
    for (j = 0; j < length / 2; j++) {
      if (str[j] != str[length - j - 1]) {
        check_pal = false;
      }
    }
    if (!check_pal) {
      cout << str << endl;
    } else {
      char temp = str[change_index];
      str[change_index] = str[change_index - 1];
      str[change_index - 1] = temp;
      cout << str << endl;
    }
  }
  return 0;
}
