#include <bits/stdc++.h>
using namespace std;
int main() {
  int test;
  cin >> test;
  while (test--) {
    char str[10000], cpy[10000], st[10000];
    cin >> str;
    int ln = strlen(str), ck = 0;
    for (int i = 0, j = ln - 1; i < ln; i++, j--) {
      cpy[j] = str[i];
    }
    for (int i = 0; i < ln; i++) {
      if (str[i] == cpy[i]) {
        ck = 1;
      } else {
        ck = 0;
        cout << str << endl;
        break;
      }
    }
    if (ck) {
      strcpy(st, str);
      sort(str, str + ln);
      if (!strcmp(str, st))
        printf("-1\n");
      else
        cout << str << endl;
    }
  }
  return 0;
}
