#include <bits/stdc++.h>
int main() {
  int t;
  scanf("%d", &t);
  char s[1001];
  int i;
  while (t--) {
    scanf("%s", s);
    int n = strlen(s);
    int same = 1;
    for (i = 0; i < n / 2; i++) {
      if (s[n - 1 - i] != s[i]) {
        same = 0;
        break;
      }
    }
    if (same) {
      int all_same = 1;
      char first = s[0];
      for (i = 1; i < n; i++) {
        if (s[i] != first) {
          all_same = 0;
          break;
        }
      }
      if (all_same) {
        printf("-1\n");
      } else {
        first = s[0];
        for (i = 1; i < n; i++) {
          if (s[i] != first) {
            s[0] = s[i];
            s[i] = first;
            break;
          }
        }
        printf("%s\n", s);
      }
    } else {
      printf("%s\n", s);
    }
  }
  return 0;
}
